Move SharePoint List Items Using Power Automate #PowerAutomate #SharePoint

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys in this video we will learn how we can move a sharepoint list item using power automate [Music] [Music] hey guys i'm deepak srivastav welcome to my channel so today we're gonna learn how we can automatically move a sharpened list item using powerautomate so this is my sharepoint site and i have a list called country report in this list i have different folders if you are wondering how you can enable folder inside the sharepoint list you need to go to the settings go to advanced settings and you have option called folder so you just need to say yes to it and once you do that you can create folders or you can create an item so in the in the sharepoint list if you select any item we have an option called move to and what this option allows us to do it allows to move this particular item to any of the different folders that are already available in this list or you can create a new folder and move this item there now this process is there this functionality is there but it is manual what if i want to automate that so whenever someone going to create a list item here based on the selected country i want that item to be automatically moved to that particular folder and i have folder for each country as listed here okay so this is what we are going to try today to find out how i can do that if i log into pro.microsoft.com and i will create a new flow i'll create an instant flow for now new step and i'm gonna see what all options or actions we have in sharepoint to move and if i search for move i got two actions move folders and move files so as you can see i can automatically move a folder or i can automatically move a file but there is no action to move a particular list item so what we're gonna do we have something called send an http request to sharepoint where we can actually call sharepoint api so now the question is do we have an api that we can use here to move a list item and the answer is yes and for that a github block that i found this is by mr leo siddell so he created this blog post where he is talking about how you can move a particular file using api so he has find out some api that actually this move command that we have seen earlier we use okay so what we are going to do we are going to take this move file api and i am going to use this move file api sharepoint list item okay so i'm going to repurpose this api though it is for moving a file and we gonna try to use it for a particular list item okay so this is the api that moved the file okay and what this api needed listed here let me filter the information from this blog post and open the visual studio code and then i'll walk you through what information you need to repurpose the move file api to move list item okay so these are the url that you need to understand the api is very simple it's underscore api sp dot move copy util dot move file by path now if you want to understand more about this particular api there is a microsoft documentation on that i will add the link for this as well so you can see how this api got set it up and what all the information you need to pass to get this working okay so this is the api you just need to know this url if you don't want to go too deep into it how it work you don't need to just remember this is the this is the url then the parameter that you can pass is overwrite true or false then we have this block of information now this information is letting this api know that which document you want to move and where you want to move so what we are going to do to reuse this for sharepoint list item we are going to work on this url so right now if you look at this url this is looking to give looking for a link to the document right both both of them for source and destination in our flow we will try to change this and point it to a particular list item this part is clear now let's go back to our flow and i'm going to delete this action and delete the trigger because what i want now i want this flow to trigger when i'm going to create a new item so when an item is created i'm going to select my site url list name okay now the first thing that i need to check whether i'm creating a folder or i'm creating an item because i don't want to move the folder right you can do that as well but this for this video we are just concentrating on a list item so i am going to add a condition here and you know there is a property called is folder if it is equal to false so if it is not a folder then i'm going to do my logic okay for now i'm just going to add a compose here paste here if you search for identifier right save it because i need to show you how to get this information okay so save it and i'm gonna test it quickly i'm gonna create a new item in this list okay click save my flow should trigger based on my item create action okay so flow done so you remember we have uh recorded the identifier if you look at this particular information you see it saying list but it is not formatted correctly so let's do the formatting okay and this is the path that you need to move a item so what i'm going to do if you go to the expression there's something called decode uri component i'm going to select that and here i'm going to pass the same identifier that we have selected okay now there is a trick if i'm going to just decode the information that i'm getting an identifier one time it's not going to give me the right information and to get the right information i need to decode it three times okay and when i say right information i mean to say in the right format so you don't have any any of those percentages character in that okay so i'm going to just do this three time decoding okay click ok now i'm going to rerun the last flow that we have successfully completed and this time when it complete you will see the result is much more readable okay so this is the path of course you have your sharepoint url this is my sharepoint url then you have list then you have country report that's the name of the list and then you have this 162 underscore point zero zero this will help you to move this particular list item from this current location where it get created to the respective folder where you want it to be moved okay so you need this path and where i'm going to use this path if i copy this just to show you i should have my url looking like this so this is my source url okay so logically this is what i want to get as a source this is my source item now we have the destination right where you want to move it everything is going to be very similar the only thing is going to change because we are moving it to a particular folder after country report that's the list name if i go back to my sharepoint and if i go to the one of the folder after country report that should have the folder name okay so if i copy so if i want to move to the usa folder and then i need to pass the title so i just need to get the path for the folder that where i want to move for the destination for source i get the path or the identifier for the item to move what i need i need the entire full path or identifier for that given folder how i can get that let's go back to the flow i'm going to add an action here okay so get items i'm going to select the url of my site list name again it's going to be the country report click on show advanced options and i'm going to add a filter query here in filter query i'm saying title equals to you need to pass the name of the folder that you are passing in your list item when you are creating so in my case when i click on the new item i have this drop down where i can select a country and this country i have a folder for each country so what i am saying in my automate flow just give me the item where title equal to the name of that country that i am selected so in the case where i've created this particular item i have selected the usa so when i'm gonna run this command get item it's gonna filter the entire list for title equal to usa and it will give me this item this folder information that's that's what we need because once we have this information i can get the path or identifier for this particular folder so this will give me the information okay and then i'm gonna add one compose here to just show you what information we are getting in that same identifier here select that if you scroll down you should have the same identifier now notice one thing if as soon as i'm gonna select this the flow is automatically going to add this apply to each loop it's okay because whenever you do get items flow thing that that you're going to get more than one item so it's going to add this loop because we know we are creating those unique folders we are not going to get these many record or we will always be getting only the one record so what you can do in that case i'm gonna move this compose outside of this loop and typing a very easy expression here okay and you see this value select that ctrl c go to your compose go to expression paste that okay and remove the curly bracket from the front and the end so this is what the information that you are getting from this get items it's an array so what i'm saying bracket 0 so i'm saying give me the first item in that array don't give me everything just give me the first item and in that first item what i need bracket single quote thirdly and then then i need to pass the name of my column okay that is identifier okay so this is the expression that you can use and let me show you here this is the expression you can use to get the first item so this will give you the first item from your get item action and then you can pass the name of the field that you want to extract okay click ok and we don't need this apply to e so i'm going to delete this one now let's try to run it again okay so follow completed successfully and now if you see here it looks very similar what we were getting for the item the only thing has changed if you see at the end it is showing me the name of the folder but you know it's not really decoded correctly so we know we're gonna decode it three time again so if i just decode this entire thing using the same expression decode uri component and i'm gonna copy this three time okay and then at the very end we're gonna close those three bracket now if i run the flow again so this is the path of the folder this is the path for the item we have both now okay now the easy part we need to create this structure okay so i'm gonna copy this entire thing and don't worry i'm gonna share the link of this flow and also copy these things into the description click add it i'm going to add another compose action here okay and copy paste the information that i have selected okay so the decoder you are the first part the source path this is my url of my site it's not going to change after that i have this information and the items i'm going to delete that and from the dynamic content this is my first compose let me rename that so this is the item path okay and this is folder part so here what i'm going to do just after that backslash now what i'm going to do i'm going to search for the item path select that okay so this is the url my tenant url or my sharepoint site url and then the path for the item same in my second or the destination url here i need to pass the folder path so we have that compose action i'm going to select that and then at the very end i'm saying titles this is the name of the item that you can just pick from your when an item is created or the title that you want to use okay click save and we will see how this compose is gonna look like so i'm gonna test again completed now if you see and if you see this information so my source url is like this so this url is correct right the name of the url of my sharepoint site list country report name of the list and the item identifier and for the destination this is the title this is the folder path and everything looks correct okay everything is ready now the only thing that we need to do we need to use the sharepoint send http action here so select that select the site address method is going to be post because we are posting this information the url as i said is going to be very simple from underscore api that's what you need to copy for the header we are going to use the standard header here except application json or data no metadata and content type is also the same okay and in the body here we're going to pass the output of the second in action this all information will go into the body of this request okay click save and just to show you here this item is still outside i'm going to run the flow now if everything is right fellow should actually move that item to the u.s folder let's see refresh item has gone if i go to usa and if i search for filter id here you go so your demo item the list item actually has been moved from outside to this particular folder let's say if you have two label of folder structure is this flow is going to work the answer is yes so for example i have usa folder then i have tx folder underneath that so this time i'm going to create another item here okay and in this field i'm going to select the text dx okay now this is the second label folder so logically if my flow is dynamic enough what it should do it should actually move this item to usa and then inside this particular folder so let's wait for this flow to trigger and see if that work okay so flow just rain and it's completed successfully and if i go to my sharepoint list i don't see that item here let me go to usa i don't see that item here as well but if i go to the tx folder look at this so that flow that we have just created is dynamic enough so if you have different folder structure or if you create a new folder it's going to automatically know that where to move that particular item another very good point that i like the most when these items are moving the id is remaining the same okay yeah so this is the quick video on how you can use power automatic flow to move item in a given sharepoint list thanks for listening and thanks for watching keep watching keep learning thank you
Info
Channel: Deepak Shrivastava
Views: 19,160
Rating: undefined out of 5
Keywords: power automate, power automate sharepoint list, update sharepoint list item using flow, ms flow tutorial, ms flow copy list item to another list, flow update sharepoint list item, ms flow copy list item, microsoft flow get items, microsoft flow tutorial, ms flow in sharepoint online, ms flow in sharepoint, power automate tutorial, power automate sharepoint team, power automate sharepoint get items, move, sharepoint, list, items, deepak shrivastava, sharepoint floder, sharepoint api
Id: mN_Jr8GW64g
Channel Id: undefined
Length: 18min 7sec (1087 seconds)
Published: Wed Oct 27 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.