Get global value when setting payload

#1

Hi
Is there a way to retrieve global variable's value when setting a payload for a node?
Lets say, in below image, I want to set the UUID hex-value coming from global-context in dashboard-button's payload option when building a command:

Currently I can do the following:

  • Change the payload type to global. and reference the variable - but will only give variable's value
  • Add a function node to build the command together with variable's value

But i'm looking for an inline approach - if possible?

Thanks

0 Likes

#2

You can use the change node, probably easiest using JSONata as this can access both the incoming msg properties, global variables and can construct strings.

0 Likes

#3

Lets say I use Inject node , so how can I use global-context when selecting payload type to JSON?
or are you saying I should use Change node to search and replace?

0 Likes

#4

Have you looked at what the change node can do? You don't want to do s/r since that is static and you want to combine data - you need JSONata for that.

0 Likes

#5

Hi @waqaslam

The Inject node doesn't support the Expression type, so you'd need to use a Change node.

You can then use the JSONata expression:

'sudo smartctl -A /dev/disk/by-uuid/' & $globalContext('my-uuid') & ' | awk "NR>6" '

Note that JSONata uses & to join strings.

1 Like