Change item's order

Hello all!

Need some help to think :slight_smile:

I have a Rg of 6 places, sorted by order (field type number, 1 to 6). so in my RG :
place xy : RG item 1 (order field =1)
place yz : RG item 2 (order field = 2)
etc etc
I send to Google direction API all addresses from this RG (field Geographical place).
The API response gives an optimized order for the route like :
2,5,3,6,4,1 (where number are items # of my RG)
I need to re-order my RG, probably by making a “change a list of things” editing the order field to match the order sent by the api.

and… blank page in my head :slight_smile: :rofl: hope I will find someone with a brain more efficient than mine on this !
thanks a lot

maybe @seanhoots ? with toolbox plugin ? referencing this post, but don’t know how to use it :confused:

I don’t know exactly how your WF are, but I suggest this way:
A) Do the API call and store the result into a state.
B) Make change to a list. In the Order field: State API Response: filtered (Address = This item address): first item’s order (or any other way to filter the result of the API with this item field to match

thannk you for taking the time @Jici

the APi can output :
an ordered list of addresses
image
like addresse6,address2,address1,address5,address4,address3
or
an ordered list of number
image
like 6,2,1,5,4,3

but what I can’t figure out is how to know the position in those list of a specific text
(what’s the position of address2 by exemple)

You need to set the filter after the route. You will be able to select address is… and after you can use first item waypoint order

don’t have access to “this tache”

image
don’t understand why

This is strange. I think that advanced is not needed in this case, but can you share the payload of the API?

hm what is a payload :slight_smile: :rofl:
MAYBE this @Jici (for now I’ve handled the problem with a recursive WF)

I’ve made some test using another request. So basically, you submit all the waypoint in your request and in the order array, this will let you know in which order they have been set. So you can use the current cell index to find the correct order in this fields
So for exemple, if you submit in this order: waypointA|waypointB|waypointC|waypointD
Google will tell you for each of them the order they have been optimized
Exemple [ 2, 3, 0, 1 ]
This mean waypointC is the first, D the second, A the third and 3 the last.
So if you use Make change to a list “address” you can use the initial order (current cell or order field initialy set) and use …'s waypoint_order:item #(current cell index or This item order field)

thanks for your precious help ! I’m gonna try this

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.