In my scenario, I have two lists. The first list is called „Car marks and Product locations“, where I store car marks and the locations where they are produced.
The second list is called „Car marks“, there I can create entries and choose between different car marks via a lookup column on my first list. The corresponding locations for the chosen car marks should automatically be stored in an additional column called „Product locations“.
The workflow that identifies the corresponding values looks like this:
First I use a „Set variable“ action to get the ID’s of the values that have been chosen in the lookup column „Car marks“ and store them in a variable called „varCarMarksLookupIDs“.
At this point it’s important to mention that I choose „Lookup IDs, Comma Delimited“ as the format for the values I store in the variable.
Then I use a „Regular expression“ action to split the single IDs and put them into a collection variable called „vCarMarksLookupIDsCollection“.
Now I’m using a „For each“ action to iterate through all ID’s that have been stored in the collection. The current ID always gets stored in a variable called „vCarMarkSingleLookupID“.
In the first step of the „For each“ action I get the product locations for the current car mark ID and store them in a variable called „vCarMarkProductLocations“ with the help of a „Set variable“ action.
In the second step of the „For each“ action I build a continuous string of all product locations with the help of the „Build string“ action.
The variable „vCarMarksProductLocationsAll“ contains all product locations. For every loop, I add the corresponding product locations for the current ID to that string.
At the end of the „For each“ action I have all corresponding product locations for every car mark in my string variable and can now update the item with it.
This is how the whole workflow looks at the end:
And this is the result after the run of the workflow: