If we have children, we start the loop to process each child. And once again, I build out the expression manually, which should look something like this: Since the parent may not always have children, we first check to ensure we returned some items using the Condition action. This is another HTTP call to SharePoint so we have ultimate control. Now we run a query for any child items, based on the ID of the parent. I’ll address adding dynamic values in a follow-up post. There are ways to dynamically add properties to your object instead of treating them all as static values. Note that in this example, I’ve chosen to use static data to build out my objects. This serves as an initialization/reset of the detailsObject as we loop, we know we aren’t dealing with stale data. Within the Apply to loop, we now use a ‘Set variable’ action to set the detailsObject with the fields pulled from the parent source. Another tip to note is that the internal name of any action will contain underscores in place of any spaces, so watch for this when updating to match your own value. You will need to update your string to match the name of your own HTTP action (or other data calls). Note that this string refers very specifically to the name of the HTTP action (‘HTTP-get_Offers’) used to get our results. This will turn into what you see below (d.results) after a save. The value should look something like this: body(‘HTTP-get_Offers’) It’s important to note the data structure returned by an HTTP call as we’ll be using this in some of our actions to help avoid the extra ‘Apply to each’ loops that Microsoft will sometimes ‘helpfully’ insert for you.īy knowing this structure, we can set the data source for the ‘Apply to each’ action manually using the Expression tab instead of selecting from the Dynamic content tab. For this, we’ll use an ‘Apply to each’ action using the results from the HTTP call. Now that we have the parent data, let’s loop through it and pull the children. While the ‘Get items’ action is very handy in some situations, being in control of exactly what I want to return is best for this application. When needing a discrete set of data, I find making a direct HTTP call much simpler and easier to control than using the ‘Get items’ action. I use the SharePoint ‘HTTP request …’ action here to return the data. Once we have the variables set, we next query the SharePoint parent list and begin building out a data object. The variable type is Object and should be initialized to an empty object using ‘’. detailsObject – this variable will hold the merged parent and child data for each item being processed.The variable type is Array and should be initialized to blank. outputArray – this is the master data container and will have an object for each line of the file.To do this, we first need to define 3 primary variables, one of an Array type and two of an Object type. In this example, I’m pulling data from two SharePoint lists, a parent and child, and then merging the data together so that there is one parent item and one child item per line. I also recommend checking out one of my other blogs, Power Automate Flows – Random Tips, Tricks, and Pain Points, for some pointers before you get started, especially if you are new to Flows. I’ve outlined here the key actions needed to create a file but have left room for you to determine the right fit with your own needs and processes. One of our clients had a need to export certain data stored in SharePoint for later importing into another analysis tool, so we designed a nifty little (not little) workflow for them. Why yes, you can create a CSV file from SharePoint data, or any other data source to which you can connect, using Power Automate Flow.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |