#How to use payload passed to subflows in run script?
6 messages · Page 1 of 1 (latest)
$trigger seems to reference the parent flow, while $last references the last operation in the parents flow. Also when calling a flow two levels deep, $last will be null. Can someone help? Thanks!
A flow object contains a variable for each operation in your flow. The variable name is it's key, which it either automatically generated, or can be manually entered when you create your flow (see the screenshot). Then, in any other operation in your flow, you can refer to that variable using the following (assuming "read_items_1" is the key defined in your operation):
{{ read_items_1 }}
Hi @boreal ferry , thanks for your reply. I tried that. I think the problem is the Run Script operation. How can I reference the specific Operation as input param?
Let's say your Flow has 4 boxes:
#1 is the main trigger.
#2 is a Read Data operation with a manually entered key of get_items
#3 is a Log to Console with a manually entered key of step_two
#4 is a Run Script operation with a manually entered key of my_script, and you want to access the data from #2 here.
If in step #4, you want to access the data returned by step #2, the Run Script should look like this:
module.exports = async function({get_items}) { // do what you want with the get_items payload return get_items; }
After an operation is complete, the data that the operation returns is always available to the rest of the Flow via it's key. If you want to restructure globally available data at some point in the flow, you can use a Transform Payload.
Hope I'm not misinterpreting what you're trying to do! 😛