Wednesday, November 13, 2019

Getting Started with Child flows in Power Automate


Child flows are new to Power Automate, and although the concept is simple, getting started is a little tricky.  I'll walk you through setting up parent/child flows within a solution and how to move data between the two.

Use a Solution

The first roadblock you might run into is that Child flows must be used inside Solutions.  What is a solution, you say? Well first, you'll find them on the left rail in Power Automate.  Second, solutions are a great way to package up one or more flows for deploying to a production environment.  This means that you don't have to export and import individual flows one at a time; instead, you export and import one solution package. (Want more?  Here's the Microsoft Walkthrough!)

To create a solution, click Solutions and then click + New solution.  Fill out the new solution form in the right rail and click Create.  

The flows

Your instinct might be to create the parent flow first, and that's fine if you have some logic you know you need to implement there first.  However, you cannot add the Run Child Flow action and save your flow without an existing child flow to point to.  For our purposes here let's create the child flow first.  Click the + New drop down in the top toolbar and select Flow.



The trigger for the child flow can be a manual button, but I prefer to use HTTP actions for my trigger and for my response.  I find this to be more flexible, and frankly, this is my comfort zone!  

Let's also add the Get items SharePoint action so that we have some data to send back to the parent flow.  I'm going to limit the count to the first item for the sake of simplicity.  

Now let's add the HTTP Response action as the last part of our child flow.  Here, set the Status Code to 200 to indicate a successful response.  In the Body of the response, add the Body from the previous Get items action.  This will serve the SharePoint items back to the parent flow, making them available for us to use.  Here's our simple child flow in its entirety: 


Make sure you rename your flow and save it.  Now let's work on the parent flow!  

Navigate back to the solution you created.  You may notice that multiple tabs open as you work on flows within a solution.  It's alright to close the extra tabs, but just know that your solution view will be updated with your changes after you save them and click the "done" button in the dialog that pops up.  

Add a new flow from the top toolbar as before.  I'm using a recurrence trigger here, but you can also use a manual trigger.  Add the Run a Child Flow action next, and choose your child flow from the drop-down.  You'll notice that the only choices available are flows within the current solution.  


We aren't finished, but this is a good spot to save the parent flow and do a test run.  What we want is the body of the response coming from the child flow because we are going to use that in a Parse JSON action next.  After your successful test run, go to the child flow inside your solution and click into the most recent run instance.  From there, copy the Body from the Response action.



Navigate back to your parent flow.  Add the Parse JSON action, with the Content being the Body from the Run a Child Flow action.  Click on use a sample payload to generate schema and paste in the response body from the child flow:


Next, let's send an email with some of the information from the child flow.  Add the Office 365 Outlook Send an email action.  For the subject, search within the Dynamic content window for Title.  Add the Title column from the previous Parse JSON action.  Notice that Power Automate will add an Apply to each container for you since it does not know how many items have been returned from the response body, only what columns and data types are being returned.


Save your flow and run a test.  You should receive an email--or emails!-- based on the Get Items action buried in the child flow.  There are a lot of possibilities here, and I'm looking forward to seeing what interesting solutions are out there!



Photo by Sergey Pesterev on Unsplash

Sunday, November 10, 2019

Tools for Newbies: PowerShell


New to SharePoint?  Finding yourself a little overwhelmed?  This is the first in a series of posts about the most useful tools for both SharePoint developers and admins. Whether you're completely new to the game or you've been in it since the beginning, these skills are invaluable.  I'll guide you through getting set up and point you toward resources that I find extremely helpful.

Today's Tool: PowerShell

Too on the nose?
I use PowerShell weekly, sometimes daily depending on what's on my plate.  This is one of those skills that is necessary for both developers and admins to know, and definitely useful for power users to understand.  Even if you're not allowed to run PowerShell at your job--maybe you're a site owner without SharePoint Admin permissions-- it's essential to know what is possible so that you can streamline your requests with IT.

There are so many PowerShell modules available that it can seem a bit overwhelming.  For our purposes, let's focus on the basics of using PowerShell against SharePoint Online.  For this you'll need a special version of the PowerShell console called SharePoint Online Management Shell  (download here!).  Management Shell comes loaded with all the modules you'll need to work with SharePoint Online.

Once you have that installed, go ahead and start up an instance of Management Shell by choosing it from your list of programs.  You'll notice that when it opens it points to a default destination.  If we were going to run a script stored on the file system we would change it, but for now this is fine.


The nuts and bolts

Everything we do in PowerShell starts with what are called cmdlets (pronounced: "Command-lets").  Cmdlets are the building blocks of PowerShell scripts, and each one refers to specific functionality and may take various parameters.  Examples of SharePoint Online cmdlets are:
  • Get-SPOSite
  • Add-SPOSiteDesign
  • Invoke-SPOSiteSwap
When it comes to SharePoint Online, the first cmdlet we need to use is Connect-SPOService.  This is the gate we need to pass through every time we want to work with SPO, and we pass in the SharePoint admin URL as a parameter.

Inside the Management Shell console, type in the cmdlet and your URL as below and press Enter.  When prompted, login using SharePoint Online Administrator credentials.  



Once connected, the SharePoint world is your oyster!  For instance, we can use the Get-SPOSite cmdlet without any parameters to return all the site collections in the tenant.  



To return a specific site, use the -Identity parameter and provide the URL of the site.  To return more information about the site, use the -detailed parameter.



There are cmdlets available for many basic processes, and PowerShell allows you to handle batch and routine processes quickly and easily.  Now that you've gotten your feet wet, go forth and script!  For the full reference, review the Microsoft Documentation.






Header Photo by Jo Szczepanska on Unsplash

Body Photo by Aaron Burden on Unsplash