FORUM COMMUNITY IDEAS SHOWCASE LEARNING CENTER

Concatenating Two Lists for an API Call


#1

Hey everybody…

I gotta make an API call that expects 2 parameters, an “account ID” and a “Region”. Currently I have 2 lists for each of the parameters, something like this:

Account ID: 123, 234, 345
Region: America, Europe, Asia

How can I concatenate those results to make single API call with both parameters like this:

123 - America
123 - Europe
123 - Asia
234 - America
234 - Europe
234 - Asia
345 - America
345 - Europe
345 - Asia

Any thoughts?


#2

@romanmg
@NigelG


#3

There is likely a more elegant way but using the Toolbox plugin (two list expressions and a javascriptToBubble element) and some javascript you can concatenate items from two lists into one like you have shown above. You should then be able to pass that list to your API call. I have done an example showing how to concatenate the list items. I hope it helps.


#4

Hey @louisadekoya

Tks for your reply… but what I really need was something like:

Pediatrics - Springfield
Pediatrics - Albany
Pediatrics - Manchester
Pediatrics - Atlanta
Trauma - Springfield
Trauma - Albany
Trauma - Manchester
Trauma - Atlanta
Patient Assessment - Springfield
Patient Assessment - Albany
Patient Assessment - Manchester
Patient Assessment - Atlanta
Preparatory - Springfield
Preparatory - Albany
Preparatory - Manchester
Preparatory - Atlanta

The demo concatenate like this:

Pediatrics - Springfield
Trauma - Albany
Patient Assessment - Manchester
Preparatory - Atlanta

Any ideas?


#5

That is quite hard to do “on the fly”.

If the data is fairly static, then I would use a Bulk API Workflow to create a new “Account Region” thing for each combo. So linking Account and Region.

And then when you added a new thing to either, then also add the new relationships.


#6

I agree with @NigelG - this is quite tricky to do on the fly. Depending on how you source the original lists, you could, as I think he’s alluding to, iterate through the account Ids and create each of the regions for them. You would indeed do this using an API workflow.

I have modified the javascript to run through all the permutations, I think, but it’s probably not in the order you might want, if that matters. Check it out. I don’t actually know Javascript - I’ve tried to adapt what I found on Stack Overflow, so I’m afraid I wouldn’t know how to order them any differently. Perhaps someone else who actually knows what they’re doing will come along and sort it - literally :slight_smile:
EDIT: I’ve made a change that seems to resolve the ordering issue.

By the way, I feel like there might be a way to use nested RGs for this but I can’t quite figure it out and I’ve run out of time. Just throwing it out there, again, in case it sparks an idea for someone else.


#7

First of all thank you so much @nigelG and @louisadekoya you are awesome!

I went for the Bulk API since one of my data was static… But I really like the @louisadekoya approach and I’m tweaking around to launch a v2 with that…

Once again, tks!