Bridge: How do I dynamically pass RowID or Object to child workflow?
Hello,
Does anyone know how to use Bridge to dynamically collect the RowID from a parent workflow to use in a child workflow?
What I'm attempting to do is have a workflow run daily to look at a sheet and collect any rows with a checkmark for "due today". Then I want the workflow to only take specific data and build a JSON string using the string compose tool.
I can build the workflow to get the sheet and get the count of rows so the child only runs X number of times. But I can't seem to figure out how to dynamically pass the RowID or the array object to the child so the child workflow can pull the specific data out, compose a string, and save it. Each time the child runs the string would be amended with additional string data.
The big challenge for me there is figuring out how to dynamically pass the RowID or the array object to the child.
Thanks,
Brian
Best Answer
-
Hi @Brian H.
In the Child Workflow Module (in your Parent workflow) you'll want to add the Array as the "number of runs".
That lets the Child Workflow know to loop through each of your individual rows from the Array as an item with specific data (1 trigger per Item in the array). It sounds like this is the step you've already completed!
Then in your Child Workflow, you can grab the reference to the row ID from the Runtime Data, which will be the information from the original workflow Array (see: Reference data from the runtime).
This is stored in the Trigger for the Child workflow. If you're not sure what the reference should be, trigger your Parent Workflow (which will trigger your Child). Then open the Run Log for that Child and find the Data Reference point for the RowID:
Trigger > Data > in mine it was id: {{runtime.data.id}}
I hope that helps!
Cheers,
Genevieve
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
Answers
-
Hi @Brian H.
In the Child Workflow Module (in your Parent workflow) you'll want to add the Array as the "number of runs".
That lets the Child Workflow know to loop through each of your individual rows from the Array as an item with specific data (1 trigger per Item in the array). It sounds like this is the step you've already completed!
Then in your Child Workflow, you can grab the reference to the row ID from the Runtime Data, which will be the information from the original workflow Array (see: Reference data from the runtime).
This is stored in the Trigger for the Child workflow. If you're not sure what the reference should be, trigger your Parent Workflow (which will trigger your Child). Then open the Run Log for that Child and find the Data Reference point for the RowID:
Trigger > Data > in mine it was id: {{runtime.data.id}}
I hope that helps!
Cheers,
Genevieve
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
-
Thanks Genevieve! This was very helpful.
One more question: Is latency a known problem with Bridge? I have observed where a workflow some times runs with minimal delay and other times it suffers significant latency, causing the trigger (checkbox) to not run until hours later.
-
Hi @Brian H.
I have a similar workflow where an Array triggers a Child Workflow to add data into a sheet. The Array can have around 200 objects in it, which generates 200 triggers for my Child Workflow. This can sometimes take up to half an hour as it goes through each item individually.
However I have not yet experienced a delay of multiple hours - each run only takes a few seconds, it's just executing them in order instead of simultaneously.
If you're experiencing delays, could it be based on a number of other workflows you have triggering at the same time? I will note that even then it should be a delay of minutes, not hours.
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
-
Hi @Genevieve P. and @Brian H.,
I am stuck on a similar problem. I've gone through this post and the "https://help.smartsheet.com/articles/2481993-reference-data-in-workflow" article. I wish there were more explicit examples.
a) If I have a parent workflow, that calls the Resource Management integration and gets returned an array in response. I want to run a loop on the array, using a child workflow.
When I create a child workflow, what do I specify as the "number of runs" ? I have tried both of the below options and none of them work, as my child workflow is triggered only once, as shown by the Run Log.
Object reference: {{states.state_get_timesheet.ten_k_ft.get_project_time_entries}}
Array reference: {{states.state_get_timesheet.ten_k_ft.get_project_time_entries.data}}
b) When passing a value from an array to the child workflow, e.g. the user_id to the child workflow and get the user name in response, should I define key/value pair? How? Can you give an example please? What gets put in the "User Id Or Email Address field" ? I've tried all sorts of things, but none of the state variables / key value pair work except for a hard-coded user id.
c) If I have a parent work flow that calls an integration and gets an array in response, can I loop over that array with the data being passed to two child functions, one after the other?
Regards,
AK
-
Hey @akhalid
I'd be happy to answer your questions in order.
A) Number of Runs
The "Number of Runs" in the Child Workflow module should be a reference to the array in the Run Log of the Parent Workflow.
B) Get User ID
In the Child Workflow, you'll want to put the run log reference to the user_id that was brought in from the trigger (the Parent workflow Array).
To find this, trigger the Parent workflow and have it then trigger the child.
Once that's happened, you can open up the Run Log of the Child to expand the Trigger, then expand the Object to see the same information as you have opened in your first image.
Copy the Data Reference to the user_id, and include this reference in the Get User module. Now this should dynamically retrieve information per-object brought in from the previous array.
C) Multiple Child Workflow trigger modules
Yes, you can trigger multiple child workflows in one Parent workflow!
However if you're looking to add information about someone that you've collected in a Child Workflow, then you'll need to put that "Add Row" module in the child workflow, not the Parent. Does that make sense?
You can still access the Parent Object information from that Child Workflow in the Trigger of the Run Log, so data other than the Get User data will be accessible.
Let me know if that helps or if I can clarify anything further!
Cheers,
Genevieve
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
-
Hi @Genevieve P. ,
Thank you for your detailed reply. I've been able to take one step further.
1. I've added the array reference in the parent workflow, when calling the child workflow in the
Number of Runs
field. I've also added the reference to{{runtime.data.user_id}}
within the child workflow and I can see that it is spitting out data. What I don't still see is the child workflow being executed twice. Below Run Log is from the parent. The child's Run Log also shows a single execution. Any idea on what I am missing?2. You said, "However if you're looking to add information about someone that you've collected in a Child Workflow, then you'll need to put that "Add Row" module in the child workflow, not the Parent.".
My question is why can't I use it in the parent, since your help article says, "You can reference data from a child workflow within the parent workflow." using
states.{{state that runs the child}}.child.{{state in child}}.value
. Prior to making the changes to make the child loop over the array, I was using{{states.get_user.child.get_user.ten_k_ft.get_user.data.display_name}}
in the parent'sSmartsheet: Add Row
and it was working fine, but it broke after I made this array-related change, although, the reference to thedisplay_name
field within the child has not changed. Need some guidance please.3. When triggering multiple child workflows within the parent (and looping over it), does the array reference need to be given in
Number of Runs
field of all the child workflows? IfSmartsheet: Add Row
is happening in the parent, how do I specify a loop count for it? Or is this limitation that you can't loop over it the reason why you suggested that theSmartsheet: Add Row
happen in the child workflow?Regards,
AK
-
Hey @akhalid
I'll answer your first question in one comment as it's pretty long!
To clarify, the Child Workflow will run once per object in the Array but the Parent workflow only runs once - what you've highlighted in red in your screen capture is expected. The Child workflow is the one that will run multiple times!
As a visual explanation, I've built a workflow that gets a sheet and I'm going to loop the rows through a child workflow.
From the Run Log, I've taken the Rows: Array Data Reference:
Then I've put it as the Number of Runs in the Child Workflow module.
Now when I trigger this, the Parent only shows one run because it runs through all of these modules just the one time. One trigger = one run.
But if I go to the Child workflow, it has 3 separate runs for each of the arrays. This is because the trigger for the Child workflow is each object of the array. One trigger = one run, so in this case there were 3 object in the array which means 3 separate runs.
Are you only seeing 1 run in the Child workflow Run Log as well?
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
-
For your other questions:
2 & 3) You answered this in your final question!
Yes, you can reference child data in the Parent workflow - but since you're looking to loop through an Array and use the unique information from each run to add multiple, unique rows, this is where the individual runs in the Child workflow will help.
The Parent workflow, as you've noted, only runs once through all the modules. You need it to continually loop through, which is what the Child workflow will do. Does that make sense?
Cheers,
Genevieve
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
-
Thank you for such detailed explanation. 🙂 This will help future learners as well.
This was very helpful. I am able to achieve what I wanted. I re-organised my workflows such that there is only one child workflow (say LEVEL_1) under the parent workflow (say LEVEL_0) so it can loop to its heart's content.
A picture is worth a thousand words. :-)
Do you have any suggestions on how to handle pagination if the rows are too many?
Regards,
AK
-
Hey @akhalid
I'm glad you found it useful! 🙂
In regards to pagination, you can control this from the Resource Management module: Get Project Time Entries
Cheers,
Genevieve
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
-
-
Hi @Genevieve P. ,
In regard to the RM to Smartsheet workflow, I've had success in transferring 67 records into Smartsheet, which is basically all the records that RM's Get Project Time Entries returned for my query parameters. In my test, the start and end dates of the query are fixed.
a) I received the error as visible in the screenshot below when I ran the parent workflow a second time. Googling does not return any result. I wonder if you can provide some guidance. The child workflow that adds a row into Smartsheet executes after gathering all data from RM, but could the child workflow be hit by Rate Limiting by Smartsheet ? Would adding the Delay utility function inside the child workflow help (by spreading out all Add Row attempts a bit)?
Parent workflow
Child Workflow
b) In regard to Pagination, you mentioned that the following section of the integration can be used. I've got a few questions here:
b1) If I limit the number of items per page, does Bridge automatically increment the page number by itself? If it does not, then would this mean that RM's Get Project Time Entries integration would have to be put inside a child workflow and then looped over by the parent?
b2) If I always want to get newer entries that have not been fetched before, do I set a daily trigger and use JavaScript to format the From and To dates?
b3) If the workflow fails to fetch from RM or Add rows to Smartsheet (like in the screenshot above), what is a graceful way to resume from where it failed? The idea that comes to my mind is to read the sheet at the beginning of the workflow and find out the last item added to Smartsheet in the previous run of the workflow.
c) For the Delay Utility Function, can the delay be a fraction of a second? I could not find a good explanation on the help page for "String". It says, "reference a piece of text and Bridge will automatically calculate a delay based on the string length.". Can you provide an example please?
Regards,
AK
-
Hey @akhalid
I'll try to run through each of your questions in order below, let me know if I've missed something.
a) Personally I haven't seen that error before and so I'm not sure what the exact cause is for "envoy overload". If this error keeps happening, I would suggest opening a ticket with Support via the Support Portal so they can look into this further.
If you're adding many rows in rapid succession, it might be worth looking into a bulk row addition via the HTTP module. This would require that you build the request body, but would help reduce the amount of needed iteration.
b - 1) The pagination will not auto-iterate, so yes, you would need child workflows for iteration as you noted.
b - 2) To get newer entries that have not been fetched before, using JavaScript would be fine if you find that easier or more flexible. An alternative would be to use the Date utilities:
Current Date/Time
andManipulate Date/Time
may be useful in this instance.b - 3) There isn't a direct module or way to pick up where an error left off currently in Bridge. This would be a great suggestion to add as an Idea in the Product Ideas and Feedback topic!
c) The Delay Utility accepts seconds only at this time, so you could add 1 second as the delay to get close to milliseconds. In your case, you'd add the number in as the "Delay" without needing to reference a piece of text at all.
Cheers!
Genevieve
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
-
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.8K Get Help
- 434 Global Discussions
- 136 Industry Talk
- 470 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 65 Community Job Board
- 485 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives