• Documentation
  • Workato Blog
  • Product Blog
  • Return to Workato
  • Login
  • Automation Institute
  • Documentation
  • Community Forums
New Topic
Discussions Recipe Building Recipe Building Questions
S

Saul Macht

started a topic almost 6 years ago
Answered

Create list from multiple locations or across different conditions

Is there any way to create a list of values from multiple locations. eg, to create a mailing list of customers from each of several applications.


Best Answer
V
Vivek said almost 6 years ago

Yes, you can create a list of values from multiple locations or across various conditional steps. 


The screenshot below represents the recipe logic for creating a mailing list of contacts and their respective application source. 


Let's look at the integration use case represented in the screenshot in detail:

  • The recipe is triggered when a CSV file is added to Box. 
(CSV file contains multiple rows of contact records. Each contact could be from either a contact from Salesforce, lead from Marketo or a brand new contact.)
  • As such, For each contact record in the CSV file, search for the contact in Salesforce or lead in Marketo.
  • If the contact is from Salesforce, Log message as Salesforce. 
  • If the contact is from Marketo, Log message as Marketo.
  • Create a List of 2 columns, one for Email of the contact and one for Source of the contact.
(The formula in the Source field in step 8 indicates that the Souce for each record will be either Salesforce, Marketo or New)

image




Answer

Vivek

said almost 6 years ago

Yes, you can create a list of values from multiple locations or across various conditional steps. 


The screenshot below represents the recipe logic for creating a mailing list of contacts and their respective application source. 


Let's look at the integration use case represented in the screenshot in detail:

  • The recipe is triggered when a CSV file is added to Box. 
(CSV file contains multiple rows of contact records. Each contact could be from either a contact from Salesforce, lead from Marketo or a brand new contact.)
  • As such, For each contact record in the CSV file, search for the contact in Salesforce or lead in Marketo.
  • If the contact is from Salesforce, Log message as Salesforce. 
  • If the contact is from Marketo, Log message as Marketo.
  • Create a List of 2 columns, one for Email of the contact and one for Source of the contact.
(The formula in the Source field in step 8 indicates that the Souce for each record will be either Salesforce, Marketo or New)

image




S

Saul Macht

said almost 6 years ago

Thanks for that Vivek! However, now I have a different kind of scenario. 


I have 2 lists of results from two different searches, at different points in the recipe. 


I want to combine these 2 lists into 1 list. 


Is it still possible do this?


1 person likes this

Patricia Guevarra

said almost 6 years ago

Hi Saul,


This is definitely still possible. An example is this recipe: https://www.workato.com/recipes/541942?st=9b1e72#recipe 


In this recipe, I have 2 search actions for Google Sheets (can be any app). Now, I want to combine the results of these two searches into one single list. This can be done by following a number of key steps.


1. Use Create List (action) on Utilities (app) --> Objective: To set up repeat action to tell Workato to repeat a particular action for a specific number of times. 

  • In this case, you want to repeat action for no. of times corresponding to the size, which is equal to the sum of the no. of records returned for both search actions
  • image


2. Use a Repeat action (For each loop) --> Objective: Run nested actions within the loop for a specific number of times

  • To set up the repeat action, input list field should map the list output from Create List

  • image


3. Use Append Item to List (action) on Lists (app) --> Objective: Combine search results in 2 steps into one single list 

  • Name your list anyhow you want. 
  • Your list item fields are arranged to combine in a sequential order from using the formula as seen below, taking from the first search, followed by the second search
  • image

 


Legend:


Formula mode format a ? b : c means to check whether condition a is true. If a is true return b, else return c

Formula mode format d.pluck ("e") [f] means to select data points b from a in ascending order of c


Index refers to the Index position for the Create List, beginning from 0,1,2 .. for position 1,2,3 .. respectively

Size refers to the size of the list of the first set of search results

Rows refers to the array or list result of the first search in b and second search in c respectively

.Pluck selects the desired data pill. In this case, "name" is desired


<Index from Create List> < <Size from first search> ? <Array result of first search>.pluck("API name of the field you want")[<Index from Create List>] : <Array result of second search>.pluck("API name of the field you want")[<Index from Create List> - <Size from first search>]


In words, it is saying "Does the item I'm processing now have an Index smaller than the first list's size? If yes, then get this field from nth item in the first list. If not, get this field from the nth item in the second list."

As a note, an index is the position of an item in the list. The first item in the list has Index 0, the second has Index 1, while the last can be represented as -1 and the second to the last is -2. This may help you understand the operation in the formula more.


Notes:

  • Learn more about Create List action: http://docs.workato.com/features/utilities.html#create-list. 
  • Create List action is different from the Append Item to List action. There are no objects inside this Create List action, you just determine the size 
  • Indented under this is the Append Item to List. For each field you need in your list, you must use the formula in the recipe I linked here
  • For more information on the use of "<" in formulas, you can refer to this article: https://support.workato.com/solution/articles/1000192505-formula-mode-comparing-values-and-setting-field-values-based-on-that
  • For more information on the use of "?" in formulas, you can refer to this article: https://support.workato.com/solution/articles/1000242547-formula-mode-special-characters-and-how-to-use-them
  • For more information on the use of "pluck" and "[Index]", you can refer to this article: http://docs.workato.com/formulas/array-list-formulas.html


I hope this helps!


C

Chandra Vippena

said almost 6 years ago

How about using the .flatten method? flatten combines two lists into a single list. However, note the data pill output would not be a list. This is useful if you would only require the array as a final step output 

K

Kyle Tan

said almost 6 years ago

My current workaround has been to combine lists using the JSON Parser action, like in step 7 of this recipe:


https://www.workato.com/recipes/554435?st=13712a#recipe


To generate the JSON Sample Document in that action, you'll need to know what the JSON output of the Append item to list action looks like. You can figure out the names of the fields like so:




In this case, the names are "departments", "projects", and so on. They go into the JSON Sample Document like this:


 

[{"departments": "", "projects": "", ...}]

 


You can also fill in dummy values if you'd like:


 

[{"departments": "All of them!", "projects": "Something", ...}]

 

Amanda Wong

said over 4 years ago

To anyone looking out for a solution on how to create a list from non-array or array data, or how to combine multiple lists into a single list, you can take a look at this recipe which showcases 4 examples:


Recipe: https://www.workato.com/recipes/815980-3-ways-to-create-a-list-additional-how-to-combine-multiple-lists-into-1#recipe


Example 1: Steps 1-3 shows how you can create a custom data list from static or dynamic custom data inputs e.g. data pills or hardcoded values

Example 2: Steps 4-6 shows how you can create a filtered list from an existing list or array data source

Example 3: Step 7 shows how you can create a list from csv-formatted data

Additional: Step 8 shows how you can combine multiple lists into a single list


1 person likes this
Login to post a comment

Still can't find your solution?

Send us a ticket, we will try our best to assist you with your problem

Documentation
Developer's Library
Tutorials
eBooks
Product Hour
Product Blog
Workato Blog
Product updates
Customer Stories
© Workato 2022   Privacy   Terms   +1 (844) 469-6752
  • Documentation
  • Workato Blog
  • Product Blog
  • Solutions
  • Forums
  • Tickets
  • Log in
  • Return to Workato
Topic views count