Change Node - access Array Object

Guys,

I have a global Object with array elements in there - the number of elements varies dependant on the time.

Is there a way in a Change Node to access the last element in an array ??

I am essentially trying to grab some dynamic info and put it out to a log file.

Here is a picture of the object/array in question

image

Currently Amber.CurrentBids has 4 elements in the array - but at the 1/2 hour and hour this gets reset to 0 and then the elements filled every 5 minutes.

So in a change node i want to set (say) msg.Amber5MinBid to global.Amber.CurrentBids."Last Array Value"

Anyway to do this or is it better with a function node ?

Craig

I have just done some messing around with jsonata instead of the global set

$globalContext("Amber.CurrentBids".[-1])

Appears from online reading that it should do it but does not

Also tried

$globalContext("Amber.CurrentBids.[-1]")

No good either

but if i try

$globalContext("Amber.CurrentBids.0")

that works fine.

So i am wondering if we do not support this in NR in Jsonata ?

Craig

what about
$globalContext("Amber.CurrentBids")[-1]

Yep that got it - thanks for the pointer !!

Craig

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.