SOLVED

Use Flow to copy selected item from one list to another list based on a dropdown selection

Copper Contributor

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.

 

GamerzKris_0-1620139584927.png

I was trying to do a flow that uses the following:

 

Gets the selected item from the list

GamerzKris_1-1620139712439.png

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"

GamerzKris_2-1620139951019.png

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.

 

GamerzKris_3-1620140193276.png

 

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.

 

3 Replies
best response confirmed by GamerzKris (Copper Contributor)
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":

 

1-Flow.png

 

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.

2-Flow.png

 

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.

 

3-Flow.png

We want to copy the airport to the appropriate country list so we add a Create item action:

4-Flow.png

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:

5-SP-Airports.png

 

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:

6-SP-Australia.png

 

So adapt that to your scenario and come back with any questions.

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User

 

@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.

@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!
1 best response

Accepted Solutions
best response confirmed by GamerzKris (Copper Contributor)
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":

 

1-Flow.png

 

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.

2-Flow.png

 

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.

 

3-Flow.png

We want to copy the airport to the appropriate country list so we add a Create item action:

4-Flow.png

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:

5-SP-Airports.png

 

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:

6-SP-Australia.png

 

So adapt that to your scenario and come back with any questions.

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User

 

View solution in original post