Iterate over table, look up, and concatenate

Options

An API request provides me with a table of user id numbers for people working on a task. I have a reference table of user id numbers, names, and email addresses. I need to look up user names and email addresses for each user id number listed on my API generated table.

Is there a way to iterate over the API generated table, to look up one email address and user name at a time, ultimately to concatenate the responses into a single string of user names and a single string of email addresses? The single string of email addresses will be used in a "send and email" action, and the string of usernames will be used in the email salutations.

It seems like the "Start a workflow for each row of a table" action wont work because all the sub-workflows would start simultaneously making the concatenation of the lookup responses impossible.

Answers

  • Aly_142377
    Aly_142377 Posts: 18 admin
    Options

    Hi Arthur,

    You're on the right track! I would suggest using "Start a workflow for each row of a table" action, and just use a master table to store the output from each of the sub-workflows.

    In your starter/main process, I would suggest first creating a table that would store the results of your look ups, let's call it "Valid username and emails", with the columns "Username" and "Email". Then, in each of your sub-workflow, you can do a table look up to see if the userID from the API generated response table matches. If it does, then add a row to the master "Valid username and emails" table with the username and email values of that matching row.

    Once all of your sub-workflows complete, you should have all the username and emails that had valid userID matches in a single table, which you then can convert to text, once for columns['Email'] and once for columns['Username'], which would give you your two strings.

    Let me know if that achieves your desired result or if you have any questions on that set up.