Forum Discussion

GamerzKris's avatar
GamerzKris
Brass Contributor
May 04, 2021

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

 

  • 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's avatar
    RobElliott
    Silver 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

     

    • GamerzKris's avatar
      GamerzKris
      Brass 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.

    • GamerzKris's avatar
      GamerzKris
      Brass 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!

Resources