Introduction
Scenario
Approach
Column Name |
Column Type |
Comments |
Title |
Single Line of Text |
City names will be stored |
State |
Single Line of Text |
State associated with the city will be stored |
Column Name |
Column Type |
Comments |
Title |
Single Line of Text |
Order details will be stored |
State |
Choice |
|
City |
Lookup |
Multi-Lookup field with Title column of City list |
Process
Follow the below steps to store value in multi-valued lookup
column:
Step 1: Create a Flow for "When an item is created" and add an action for Initialize Variable. Provide the variable name "AllCities" and select Array in Type.
Step 2: Add an action for "Get items". We will get all the cities for the selected state using this action.
Step 3: Select site and list In "Get items" action and also add "filter query" to get cities of selected state only.
Step 4: Now add Apply to each action. We need to iterate through each returned items from "Get items" action and append IDs in the array variable.
Step 5: In Apply to each action, select the value of "Get items" action from Dynamic content as shown below.
Step 6: Now in Apply to each, add "Append to array variable" action.
Step 7: In the Name field, select the array variable "AllCities" which we initialized at the top. And in Value
pass the JSON for ID as below format and select expression int(items('Apply_on_each')?['ID'])
in a value of id.
{
“id”: int(items('Apply_to_each')?['ID'])
}
Step 8: Now add a new step for the Update item. Select site
address and list name. Now in the Id field, select the ID from Dynamic content as shown below:
Step 9: Here Title is a required field, so we need to select
the value of Title field also.
Step 10: Now In a City field, click on Switch to input array
icon as shown below:
Step 11: Once we click on it, it will show the text box. Now
select the array variable "AllCities" from Dynamic content as shown below:
Step 12: Save your flow and add a new item to the Orders list. While creating an item, we are not selecting the city (it's hidden from the form), we are only selecting the State.
Step 13: Once the flow is executed, we can see all city of
selected state populated in the City field.
Conclusion
This is how we can dynamically store value in a multi-valued lookup column using Power Automate (MS Flow). Hope this helps!
Is it possible to refresh the images in this post? They seem to have disappeared. Thank you
ReplyDelete