guys, need some help again.
i want extract latest notification from attributes, but im stuck…
payload is:
path is data.attributes[“2023-05-28 08:13”] but attribute name changes… any help?
guys, need some help again.
i want extract latest notification from attributes, but im stuck…
payload is:
path is data.attributes[“2023-05-28 08:13”] but attribute name changes… any help?
The JSONata expression you require is
(
$keylist:=data.attributes.$keys()[$contains($," ")];
$lookup(data.attributes, $keylist[-1])
)
Edit - neater code…
(
$a:=data.attributes;
$k:=$keys($a)[$contains($,":")];
$lookup($a, $k[-1])
)
You did not post your flow, and only a picture of the data, so I had to guess as to what you really wanted.
Note- this is a JSONata (expression), not JSON (data structure). It can either go into a change node, or directly into the output property option of the current state node.
If, as you have above, you are saving the entity value into msg.data, then you can use a following change node, and in that set msg.payload to the outcome of the JSONata expression above - use the ‘J:’ option.
Alternatively, you can do this directly in the current state node.
(
$a:=$entity().attributes;
$k:=$keys($a)[$contains($,":")];
$lookup($a, $k[-1])
)
This should work, but I can’t test this in full.
You also don’t really need the msg.data property, so you can delete this from the list if you like.
Perfect. THANK YOU!