Power Automate BULK / Batch Create Dataverse records FAST with the Web API

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
if you have to create a bunch of Records inside a data verse and you're doing something like this with an apply to each and add a new row totally works but there's a way you could do it with just one action you can use the web API and put all 20 30 50 items in there and do it in just one call in my example I'm getting a bunch of files from SharePoint and then I want to turn them into tasks instead of using the add a new row data verse action I'm going to click the plus and add one of my favorite called invoke in HTTP request and make sure to pick the pre-authorized one so that way you're authenticated right away now you might not see this menu right away you might have to come up here and click change connection and if you click add new you might see something like this all you need to do is hop into your Dynamics or dataverse instance copy the URL up to the Doom hop back in here paste it get rid of the Slash and then paste it again and click sign in you want to come into here and select post and then for the URI you only have to put part of it and it's this api. data 9.2 batch the reason I know that is because it's coming from the documentation on batch requests I'll link to this and if we click show all we need to add some headers and the body and it gets a little tricky here's what we want to build I know it looks gnarly but we have to first start with just this piece up here these are our headers so I'm going to start with o data one for one copy and content side gets a little weird once I get to boundary because it's in quotes so I'm going to do equals quotes and I'm going to need to generate some kind of good we'll do that in a sec but if I go underscore batore let's just say I type in 1 two 3 right away I'm going to get this enter valid on what you need to do is make sure to escape all of your quotes and then it stops yelling at you all right let's make our goid first so I up here created a new compose action and all I did was come in here into the expression just type in the word guid type in the word guid lowercase and with parentheses click add that's it so now when you run it you're going to have a nice gooid here so now we can repurpose this by going down here into our HTTP request and then in here instead of this one two three let's go use our brand new guid and let's click save heads up this is going to randomly delete your backs slash you're going to have to type it in again cuz it's going to throw this airor message at you but then you'll be good to go we finished the top part let's move to the next sections they're surprisingly simple this right here is repeating itself exactly the same every time so I have my individual tasks here and between them I just got to put this text here so this isn't that overwhelming and here is where the differences are here we put the schema name of the table in this case task if you're doing a custom table it's going to be something like this and these are just the columns so if I open up my task table in a solution and I look at one of the columns and then come down here and look at the schema name that's what this is right here and this is just a lookup and if you're wondering like kind of like what this is here if we hop back if I use the add a new row task and I put here the subject and the accounts if I click on code view I'm going to see here subject and regarding ID look it's exactly the same as this so power automate is actually just doing this behind the scenes using the API let's start looping and creating all of these individual tasks side note if you're solving these types of complex problems in the Power Platform it probably means you're ready to become a Solutions architect I've got a specific training just for that in the description maybe you want a higher salary or maybe you want to make sure you're building complex applications the right way it's already helped 26 people in the last 3 weeks all right let's get back to it so I made a new empty string variable and then I'm going to use the apply to each to go populated to build this so in here I'm going to start typing all of this so it begins with batch uncore and let's select our guid from earlier and then under here we got to do content type and it's just uh copy and paste from here and then we want to open it up to our actual object type in here subject and then whatever value I want in this case I want the from my SharePoint action I'm going to get Json that looks like this and I just want the name property since I am inside of an apply to each I can go into here select the expression and type in item and then the property click add as you've probably done in data verse many times you have to put the plal name of whatever lookup table you're connect to and then you got to add the goid here except you don't do the goid with quotes so I'm going to just hardcode it because I'm not going to dynamically generate it so let's steal it from up here and then pop that right into here so I'm going to hit save your final result should look like this don't forget the commas make sure you got the right spacing here so it doesn't mess up anywhere because if you do have an error here you're going to get super vague error messages like this and if if we run this and we open up our batch body after our apply to each we look into here and it's like oh all right that's that's pretty neat the subject here is just the name of the files I'm getting okay we've just recreated this now the moment of truth let's hop back into our HTTP request and then down here in the body let's add this request body we just made click save and if we come up here and rerun it again green is good and this looks promising but the proof is in the pudding if I go here and refresh booah it all created all the records that I had plus it put the regarding field some other things to consider is if you notice I can put tasks here but can I switch it up and put other tables here so maybe you can make multiple different kinds of records at at the same time worth exploring some further thoughts to consider is how many records can this thing handle how many is too many does it start dropping them after a certain while and even though you can do this to create multiple records in one go do you want to is data flows a better example how does this handle errors like if one of them fails these are the questions that Architects care about if you want to start thinking in this bigger level I highly suggest the training and as always feel free to leave a comment if you got any questions I'll be sure to answer it and like And subscribe
Info
Channel: Untethered 365
Views: 1,933
Rating: undefined out of 5
Keywords:
Id: e2zuEBdas0g
Channel Id: undefined
Length: 7min 36sec (456 seconds)
Published: Thu Apr 11 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.