Copy List Item From One Site Collection To Another Through Flow

In this blog, I am going to explain how we can update or add an item from one site collection to another through Flow without using web service as we used to do it in SPD workflow.

First, select Flow, as shown below.

SharePoint  

Click "Create from blank", as shown below.

SharePoint

Click on "When an item is created", as shown below.

SharePoint

Fill in the site collection address and provide the list name in which we are going to create an item.

SharePoint

Now, the scenario is that we are going to create an item in ‘List1’ of ‘coll1’ which is a site collection. Then, we are going to create an item in ‘List2’ of another site collection with the same properties.

I have created two lists with the same column names and with the same data types on both the site collections. Below is the list of data types of columns that I have created.

TitleSingle line of text
AddressMultiple lines of text
Employee codeNumber
Is MarriedYes/No
EmployeePerson or Group
Date of JoiningDate and Time
Working shiftChoice
Profile linkHyperlink or Picture
Employee pictureHyperlink or Picture
SalaryCurrency
SkillsManaged Metadata

Skills is a Taxonomy field. Copying Taxonomy values from one Managed Metadata field to other only works if the terms are from the same term set which means we have to create a Term set at the tenant level, as shown below.

SharePoint

We can select a term set for a column, as shown below.

SharePoint
SharePoint

I have initialized a variable to check if an item already exists in ‘List2’ of site collection ‘coll2’. For this, I am going to use ‘Get items’ action to query the list items from List2 of ‘coll2’.

SharePoint

Above, we can see that I have applied a filter query on Employee column of ‘List2’ in site collection ‘coll2’.

I have also mentioned Top Count = 5000 because by default if we do not specify anything then ‘Get Items’ action bring only 100 items.

Also, make sure to manage your indices on columns that you intend to query so that we want to query more than 5000 items we could do that.

Now if ‘Get Items’ action return item count is greater than 0 then “Apply for each action would be executed” as shown below.

SharePoint

If the item already exists, then we can set variable ‘IsItemExists’ to true, so that once the control is out of ‘Apply to each’ action, we can apply a condition to check whether we need to create the item in List2 or not.

Below is the condition.

SharePoint

‘Create item’ is executed if the condition is true.

SharePoint

Below ‘Create Item’ action with all the properties.

SharePoint