I have a question regarding message filtering. I have a service that calls get_events for a specific calendar and I would like to forward just the one date I need. Can I do this ? if yes how?
You can see the service on the photo and what I Would like to forward is just the end_time and not the whole object
You would use the path
payload["calendar.pogo"].events[0].end
If you click the little button next to the value, it will give you the path.
if you mean to use as output for msg.payload the J expression and use that I have done it before and on the debug it says undefined
In JSONata, to reference key names with special characters, use the back-tick
payload.`calendar.airbnb`.events[0].end
The [ ]
is array selection and does not work in quite the way you are expecting, ie the usual JSON reference syntax does not work.
And before you ask…
In the output properties you have to use msg.payload (or whatever) = results in the Call service node to get the return from the service call. There is no $results() function.
You could try using a second rule, msg.payload = J: expression, however I have found that does not always work. Node-RED is asynchronous, and whilst Change nodes appear to correctly cascade the rules (so you can use the result of a previous rule output higher up the list) in the Call service node it does not (always / ever) work.
Safer option is to output the results in msg.payload and then use a change node to strip out the subparts you want.
Ok got it. I was keeping the date I need inside the function but I would like to do have ti as an input. It did work now. I will check if it works without errors. Thanks for your help!