May 04 2021 08:04 AM
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 just selecting the item and moving to another list directly, if it was possible to 'Select which list an item is being copied to' from a dropdown selected value in the 'For a selected Item' workflow.
I was trying to do a flow that uses the following:
Gets the selected item from the list
and simply based on what the condition of the selection was, copy the list item into the selected list (There are x2 "Apply to each" after the Get Item, one for each list from the dropdown menu) where the only differences are the "Condition - Select Fiscal Quarter is equal to Q1 OR Q2" and the "Create Item in List Q1 OR Q2"
But I keep getting an error when I run the test stating there is an issue with the Apply to Each action with not recognizing a string and needs to be a valid array.
I am assuming instead of using the direct point to result of choice from Q1 or Q2, that I would instead need to use a 'Filter Array' expression that assigns a value to the result, but I am not sure if what I am trying to do is even possible. It sounds simple, but I thought I would ask. Thanks for your help.
May 05 2021 03:39 AM - edited May 05 2021 03:43 AM
Solution@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
May 05 2021 04:34 AM
@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.
May 10 2021 11:14 AM
May 05 2021 03:39 AM - edited May 05 2021 03:43 AM
Solution@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