Is it possible to create a list using the "List" utility, and then append to the created list using the "List" utility?
For example, my recipe will receive a list of Object IDs. I want to iterate through the IDs and perform an action once for each unique ID. If the list [123, ABC, 123, 123] is received, I only want to perform two actions (once for 123, and once for ABC).
Ideally I would like the recipe to be structured as follows...
1. Receive Object IDs
2. Create a List
3. For each Object ID, do the following
i. If the List does not contain Object ID, do the following
You can use the operator << to append data at a later step to a data pill that was created in an earlier step. If you are in doubt, click on Use this recipe and give it a test. You should receive an email titled IDs, containing this array: ["", "1", "2", "3", "4", "5", "6", "7"]
The first is a blank because that was the blank array initialized, and the IDs 1-7 were later appended to the data pill in the repeat action.
Thank you for the feedback! The articles provided more insight into how lists work within Workato.
However, I am still getting stuck on one part of the puzzle.
"1. Receive Object IDs
2. Create a List
3. For each Object ID, do the following
i. If the List does not contain Object ID, do the following
a. Perform action
b. Add Object ID to list
4. Stop Recipe"
I'm going to switch over to programming terms since it may be easier to understand the logic.
- In step 2 (Create a List) I want to initialize an empty array to store any Object IDs that have been processed.
- Step i (If the list does not contain Object ID, do the following) should check the array for any matching Object IDs added to the empty array.
- Step b (Add Object ID to list) would append the processed Object ID to the array initialized in step 2.
Where I am getting stuck is how to reference the appended Object IDs from step b, in step i. Workato's workflow is very procedural, and there does not seem to be a way to reference step output from later steps.
Amanda Wong
said
about 7 years ago
Hi Ryan, in step 2, are you looking for a list that you can keep adding Object IDs to, across multiple jobs? Do you want to continually refer to this list and add new Object IDs to the list? If that is the case, have you considered using lookup table: http://docs.workato.com/features/lookup-tables.html?
You can lookup entries (returns 1 result only), search entries (returns list of multiple results), update entries, and add new entries.
Note: The List app only allows you to store data within one job. In fact, the Append item to List action creates a new list each time it is used. Currently, if you wish to combine 2 lists into 1 list, there are non-elegant ways of doing it that is discussed in one of the forum threads: https://support.workato.com/support/discussions/topics/1000084104.
R
Ryan
said
about 7 years ago
Hi Amanda,
In this scenario I only want the Object IDs to be referenced during the job. Is it possible to add items to a Lookup table and have them removed once the job is complete?
You can use the operator << to append data at a later step to a data pill that was created in an earlier step. If you are in doubt, click on Use this recipe and give it a test. You should receive an email titled IDs, containing this array: ["", "1", "2", "3", "4", "5", "6", "7"]
The first is a blank because that was the blank array initialized, and the IDs 1-7 were later appended to the data pill in the repeat action.
Would this help?
1 person likes this
R
Ryan
said
about 7 years ago
I can work with this! Thank you for the help Amanda, it is greatly appreciated.
In cases such as this, it would be very beneficial to be able to assign global variables.
Maybe have a section between the Trigger and Action titled "Global Variables" where developers can assign, manipulate, and access job specific data. These would then be available for each step in the recipe if desired.
AshleyLangefeld
Create and Append to a List
Hello,
Is it possible to create a list using the "List" utility, and then append to the created list using the "List" utility?
For example, my recipe will receive a list of Object IDs. I want to iterate through the IDs and perform an action once for each unique ID. If the list [123, ABC, 123, 123] is received, I only want to perform two actions (once for 123, and once for ABC).
Ideally I would like the recipe to be structured as follows...
1. Receive Object IDs
2. Create a List
3. For each Object ID, do the following
i. If the List does not contain Object ID, do the following
a. Perform action
ii. Add Object ID to list
4. Stop Recipe
Hi Ryan, since you are only looking for the IDs to be referenced in the job, perhaps you can take a look at this sample recipe (https://www.workato.com/recipes/616355-append-new-data-to-data-pill?st=a600a0#recipe) to understand how you can append new data to a pill to achieve your use case.
You can use the operator << to append data at a later step to a data pill that was created in an earlier step. If you are in doubt, click on Use this recipe and give it a test. You should receive an email titled IDs, containing this array: ["", "1", "2", "3", "4", "5", "6", "7"]
The first is a blank because that was the blank array initialized, and the IDs 1-7 were later appended to the data pill in the repeat action.
Would this help?
1 person has this question
Amanda Wong
Hi Bill and Ryan,
Could this forum topic - How to split string into a list of elements that I can iterate through? - be a solution you're looking for?
You can check out these recipes:
(1) https://www.workato.com/recipes/610989-create-list-from-an-array#recipe -- This recipe uses .uniq to return unique values in an array before creating the actual list for iteration
(2) https://www.workato.com/recipes/609217-create-list-from-string#recipe
Ryan
Hi Amanda,
Thank you for the feedback! The articles provided more insight into how lists work within Workato.
However, I am still getting stuck on one part of the puzzle.
"1. Receive Object IDs
2. Create a List
3. For each Object ID, do the following
i. If the List does not contain Object ID, do the following
a. Perform action
b. Add Object ID to list
4. Stop Recipe"
I'm going to switch over to programming terms since it may be easier to understand the logic.
- In step 2 (Create a List) I want to initialize an empty array to store any Object IDs that have been processed.
- Step i (If the list does not contain Object ID, do the following) should check the array for any matching Object IDs added to the empty array.
- Step b (Add Object ID to list) would append the processed Object ID to the array initialized in step 2.
Where I am getting stuck is how to reference the appended Object IDs from step b, in step i. Workato's workflow is very procedural, and there does not seem to be a way to reference step output from later steps.
Amanda Wong
Hi Ryan, in step 2, are you looking for a list that you can keep adding Object IDs to, across multiple jobs? Do you want to continually refer to this list and add new Object IDs to the list? If that is the case, have you considered using lookup table: http://docs.workato.com/features/lookup-tables.html?
You can lookup entries (returns 1 result only), search entries (returns list of multiple results), update entries, and add new entries.
Note: The List app only allows you to store data within one job. In fact, the Append item to List action creates a new list each time it is used. Currently, if you wish to combine 2 lists into 1 list, there are non-elegant ways of doing it that is discussed in one of the forum threads: https://support.workato.com/support/discussions/topics/1000084104.
Ryan
Hi Amanda,
In this scenario I only want the Object IDs to be referenced during the job. Is it possible to add items to a Lookup table and have them removed once the job is complete?
-Ryan
Amanda Wong
Hi Ryan, since you are only looking for the IDs to be referenced in the job, perhaps you can take a look at this sample recipe (https://www.workato.com/recipes/616355-append-new-data-to-data-pill?st=a600a0#recipe) to understand how you can append new data to a pill to achieve your use case.
You can use the operator << to append data at a later step to a data pill that was created in an earlier step. If you are in doubt, click on Use this recipe and give it a test. You should receive an email titled IDs, containing this array: ["", "1", "2", "3", "4", "5", "6", "7"]
The first is a blank because that was the blank array initialized, and the IDs 1-7 were later appended to the data pill in the repeat action.
Would this help?
1 person likes this
Ryan
I can work with this! Thank you for the help Amanda, it is greatly appreciated.
In cases such as this, it would be very beneficial to be able to assign global variables.
Maybe have a section between the Trigger and Action titled "Global Variables" where developers can assign, manipulate, and access job specific data. These would then be available for each step in the recipe if desired.