Increment an http Post Call to create a loop

#1

Is there a way to add an increment to this http post url to create a loop in a flow?

https://maps.googleapis.com/maps/api/place/details/json?placeid=google_places_text_search.data__results__0__place_id

then

https://maps.googleapis.com/maps/api/place/details/json?placeid=google_places_text_search.data__results__1__place_id

etc., etc?

The number of post calls will vary on the number returned in a previous call in the flow.

(Daniel Beckett) #2

It looks like you’re using data outputs for the webhooks which unfortunately means that you won’t be able to use a variable to determine which output should be used so that you can loop through.

#3

Yes I am using data outputs. It seems you would have a way to do this similar to magic repeat.

(Daniel Beckett) #4

You can use Flow labels to set a start point and then use GoTo Label to jump back with a filter set for X number of required times (please note that there’s a maximum number of 20 loops). There’s a support article on Using Label and Goto a Label in Flow XO that has more information if you’re interested.

The magic repeat with a data output could potentially work if you pass it into something like the code service and handle the outputs as variables in the code block.

I suppose if you really wanted to use a simple solution then you could have your webhook actions setup for however many maximum number of webhooks will be required and then Filter each one so that it only runs if google_places_text_search.data__results__X__place_id is not empty.

E.g.

With a filter for…

Granted, this isn’t the best method if you have a lot of outputs to deal with but it is a much easier solution to implement :slight_smile:

#5

I won’t go into the details now but I think I could make this work if you can show me how to do a replace in a text string of the first comma only. I would use this to parse a magic repeater output and loop process.

Can you show me how to replace the first comma and only the first comma of a text string. I am not a coder so an example would be great.