How to copy list items from one SharePoint list to another list (Part 1)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] yesterday I got a question that was very interesting how can we use a flow to copy list item from one list to another we know there is a copy file action but there is no copy list so how do we do that is gonna be very interesting typically you can say okay I read it read item from one place and then I create the item in another list well yes but if it was not because of something very interesting I wouldn't have made the video for this so let's get into it and see the surprises in flow creation let's have a quick look into the problem definition we have two lists we have list one and list two they are located on two separate SharePoint sites site one and side two by the way these are modern sites so two communication sites basically each one of them is a separate site collection so because they are into separate site collections we do not have a shared content type regardless every time an item is created in list one we need to take a copy of it and take it to list two I really didn't want to do it without content type so I decided to take it to the next level so I went to the SharePoint Online content I pub and I created a content type here and then I published it to the entire tenancy then I could go there and write it to list one and list two if you have worked with the content type hop that's fantastic if you haven't you may want to look it up but if you are interested to learn about content type hop and how you can share a content type across site collections just put it in the comments below and I will show you how to do it it's been actually a long time since I wanted to do that but I never felt like okay who's gonna be interested in the content iPod so let's go first to the content type hub and I will show you the content type that we created then we will go to site 1 and site 2 and we will see the setup then we will go to the power automate and we create a float that whenever an item is created in list 1 he takes a copy of it and creates it on this to tell the SharePoint Online content type hub so whatever the tenancy that you have if you go to the slash sites slash content type up there is a dedicated content type hub in every sharepoint online tenancy we used to create it ourselves and enable the services on sharepoint online you really don't need to do that Microsoft has done it for you so whatever the content type that you create here you can publish it for the entire tenancy so basically all the site collections will inherit that to do that I went here to site settings and under site content types and under site content types I created a content type called demo content type and if I open it you will see there is title CD company email and hobbies and each one of them is a side column doesn't matter after it is done I clicked on manage publishing for this content type and I click on publish and I pressed ok if I make any changes in this content type I can republish it and press ok the only thing is that if you do that it usually takes around an hour for this content type to be published to the other side collections regardless I have done that before and now if I go to the other two sites that I told you site one under site one I have list one and this list one actually if you want to see the content types on the list setting it has the demo content type and I also add the same thing to the side two on the list too if I go again to the list settings again we have the demo content types so we have identical content types in both sites which means they have identical content type ID which is great this is exactly what we want so now if I copy an item from list one in site one - list - inside - I can copy the fields and the content type so even if there is a mix of content types in site one in list one I can basically copy every record with the right content type now let's see how we can do it in flow as always I go to flow that Microsoft comm I click on create and just like before I do it with instant flow and I skip everything first I give it a name I say list item copy demo and we want to use SharePoint I click on SharePoint and when an item is created fantastic now I need to pick the source site so I go to site 1 I get a link here I go to the flow click and Akash custom value and I just paste the URL here so this is my source the list name that I want to pick is list 1 now here's interesting one if I click on show advanced option it has only one option which is avoid column threshold issues by only using columns defined in the view at the moment every column that they want to copy is there but if it is not there there are columns that you have but you don't display it in the default view and you want to bring everything here even the hidden fields you can click on this and you can say use all columns so basically no limit for the columns that you want to bring I use this one so that we see what are the other columns that they come here backstage so so far the never right item is created on list one on site one if we get a copy of it inside from on the next step we need to again go to SharePoint select and I go to create item when I click on create item I can pick the second site URL I already have it if you don't have it just again go to custom and just copy it and paste the URL the list name is going to be listened to this is the interesting part I have titled city company and blah blah blah and all those things including content type ID and I have this content type ID again because if I go here I've actually added the content type to the view now here is the interesting part here we also have Advanced Options and in this advanced option again it says avoid columns also it basically shows everything that I have in the view but if I click on this drop-down it says use all columns do not limit and if I click on it you don't get anything I wish Microsoft fix this basically I was expecting to see a long list that I can work with it and to make it even worse if I want to go back to where I was and I say ok all items and you see it doesn't even bring it this is very interesting so basically we are kind of stuck here and this UI is not doing the job which means when we are in a situation like this we delete it and we add it again so SharePoint I go to create item create item I click on here side to is my destination I picked list 2 this time I do not go for the advanced option so I do not touch this item I go for the title I get the title from when the item is created and now you see because this one basically gets all the fields you see a long list of columns title I get a title from here city I get a city from here company I get a company from here email I get email from here hobbies if there is any field like hobbies we get it from here and here is the interesting part I can pick the content type from the drop-down or I can enter the custom value and I can come here to the source and I get the content type ID and bring it here ok keep it in mind we have content type name and we have content type ID when we want to assign the content type iviva sign it they assign the ID to ID and you're done let me just save it ok got it now let's go and test it save again I go to site 1 I add a new item here there is only one content type here title is gonna be test item for demo city Mississauga company home where for example email my email at somewhere calm hobbies hunting fishing loving every day and there's no attachment I click on save and get the to go let's go to the other site under list - and see if we get it now if you remember depending on your subscription that may take something between two three minutes for the paid subscription to something around 15 minutes for a free subscription of flow so if i refresh it hopefully I will see it not yet so let's get so let's wait and see when it's gonna show up there we go we got lucky we got it in less than 30 seconds and we have exactly all the fields that we had in sight one inside site - now here is a question what about the other fields how can I transfer the files that they are not there while I do not have access to this to the other fields we're using the create item well the answer is very simple always you have a plan B called SharePoint REST API you can always use the SharePoint REST API like here let me just google it so SharePoint or REST API create list item so I just go to the first link and search for create and let's see not here create less item here is the rest API basically you can add any fields that you want when you create and this one always works how do you call it from inside Microsoft flow I already have a YouTube video I just put the link right on the top of this video you can click on it and watch it so basically it gives you full access to do everything that the Web API can do from Microsoft flow when you want to do something inside SharePoint I hope you've enjoyed the video thank you for watching and see you in the next video [Music]
Info
Channel: Alireza Aliabadi
Views: 21,005
Rating: 4.944056 out of 5
Keywords: SharePoint, List item, Power Automate, Flow, Content Type, Content Type Hub
Id: YlRidNZInqw
Channel Id: undefined
Length: 14min 35sec (875 seconds)
Published: Sun May 10 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.