Forum Discussion
GamerzKris
May 04, 2021Brass Contributor
Use Flow to copy selected item from one list to another list based on a dropdown selection
Hello, I am relatively new to Power Automate Flows, and I was wondering if anyone has figured out how to copy/move a list item from one MS List to another MS List using a flow, but instead of jus...
- May 05, 2021
GamerzKris you can do this quite easily using a variation of my example in the images below which copies an airport from a main list of all worldwide airports into a list for a specific country which the user selects when the flow runs. As with your flow the trigger is "For a selected item":
Next you need to initialize a variable to hold the option selected.
Next, add a get item action to get the relevant item from the list.
Next, add a type of condition called a Switch - you can have up to 27 separate cases, so it's "if the country in the varCountryList variable is Australia then do some actions, if it's New Zealand then do some actions, if it's United Kingdom then do some actions, if it's none of those then do some actions (or not)". In your scenario you would probably only need Q1, Q2, Q3 and Q4.
We want to copy the airport to the appropriate country list so we add a Create item action:
If you wanted to move the item instead of copying it you would then add a Delete item action to delete it from the master list of airports.
Now to trigger it you just need a JSON-formatted button your list:
The JSON for that is as follows and you will need to change the txtContent line to whatever text you want in your button, and also change the ActionParams line to include the id of your flow:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "button", "txtContent": "Copy to Country List", "customRowAction": { "action": "executeFlow", "actionParams": "{\"id\": \"c9393a9a-5f4f-48c3-802d-6938ba8cde4b\"}" }, "style": { "background-color": "#f14717", "color": "#ffffff", "outline": "transparent", "border-width": "1px", "border-style": "solid", "border-radius": "5px 25px", "border-color": "transparent", "cursor": "pointer", "font-size": "12px" } }
I selected Abingdon Downs Airport in Australia, the flow ran and it copied it over to the Airports Australia list:
So adapt that to your scenario and come back with any questions.
Rob
Los Gallardos
Microsoft Power Automate Community Super User
RobElliott
May 05, 2021Silver Contributor
GamerzKris you can do this quite easily using a variation of my example in the images below which copies an airport from a main list of all worldwide airports into a list for a specific country which the user selects when the flow runs. As with your flow the trigger is "For a selected item":
Next you need to initialize a variable to hold the option selected.
Next, add a get item action to get the relevant item from the list.
Next, add a type of condition called a Switch - you can have up to 27 separate cases, so it's "if the country in the varCountryList variable is Australia then do some actions, if it's New Zealand then do some actions, if it's United Kingdom then do some actions, if it's none of those then do some actions (or not)". In your scenario you would probably only need Q1, Q2, Q3 and Q4.
We want to copy the airport to the appropriate country list so we add a Create item action:
If you wanted to move the item instead of copying it you would then add a Delete item action to delete it from the master list of airports.
Now to trigger it you just need a JSON-formatted button your list:
The JSON for that is as follows and you will need to change the txtContent line to whatever text you want in your button, and also change the ActionParams line to include the id of your flow:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "button",
"txtContent": "Copy to Country List",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"c9393a9a-5f4f-48c3-802d-6938ba8cde4b\"}"
},
"style": {
"background-color": "#f14717",
"color": "#ffffff",
"outline": "transparent",
"border-width": "1px",
"border-style": "solid",
"border-radius": "5px 25px",
"border-color": "transparent",
"cursor": "pointer",
"font-size": "12px"
}
}
I selected Abingdon Downs Airport in Australia, the flow ran and it copied it over to the Airports Australia list:
So adapt that to your scenario and come back with any questions.
Rob
Los Gallardos
Microsoft Power Automate Community Super User
- GamerzKrisMay 10, 2021Brass Contributor@RobElliot, Yes, this solution worked very well. I've tweaked the varCountryList to my varFiscalList, grabbed the Flow ID from the 'Website Address Bar' for my flow, and have set the options to each List. Ran the button, and worked like a charm! Thanks again!
- GamerzKrisMay 05, 2021Brass Contributor
RobElliott Thank you Rob, I will experiment with your suggestions and see if this solution works, and will advise of what I was able to resolve this with, for the community to use as well.