[PowerPlatform] Move list item with attachment to another list based on metadata value

OK, so we will take a Modern SharePoint Team site and two custom lists.

 

Both SharePoint custom lists will have the following columns:

Note: the “POC project name” is in fact the “Title” default column that has been renamed as you can see in the URL section of the screenshot below:

Now, we want that each item from the list “Mike Tech List Test 1” that has the “Retired” Field set to “Yes” to be moved to the list “PBNET TEST LIST 22”

In order to do this, we will create a PowerAutomate Flow:

  • Select New – Instant – From Blank
  • Give your flow a name and choose skip
  • Choose the schedule when your flow will run:

Let’s say once a day:

  • Click on “Next Step” and choose “SharePoint – Get items”

 

 

  • the next step will be a loop so we will use “Apply to each”

And apply the loop to the list of items

  • Within the same block, we will apply the condition for our Retired column:

  • we will work on the Yes branch of the logic, since the No branch has no use.
  • So let’s get all the attachments for the items:

  • Now we need to get the attachment contents of each item in the original list, create the new item in the new list and add its attachment:

 

 

OK, so now we have our items and attachments from the original list. So let’s create the item in the new list:

  • add an action
  • create item
  • Fill in the site address, new list name (PBNET TEST LIST 22) and all the fields required

  • and add the item’s attachment (add attachment action):

  • and now, outside the “attachment contents block”, create a step to remove the item from the original list:

To ease up things, here’s the overview of the actions:

OK. So now, let’s test our flow:

  • if the Retired Column is set to “No”

  • if the Retired Column is set to “Yes”

And the item will appear in the new list and get deleted from the old list.

Enjoy!