This blog post describes a way to capture links to running Flow instances and other metadata to a SharePoint List using HTTP REST. A Flow Owner can use information in this list rather than the Flow Portal to find a specific running Flow instance more quickly.
We designed a Flow that our client uses to approve promotional campaigns for a variety of product lines. A Project Owner enters information about a campaign including proposed costs to a SharePoint list and launches a Flow that takes this Project through multiple approval levels based upon product line and spending limits.
At any one time, there can be 25 or more Flows in various states of approval. One thing that becomes apparent when troubleshooting Flows is easy access to detail necessary to quickly identify a specific running instance. As of this writing, the Flow Portal provides information shown in the following screenshot.
Figure 1 - Current Flow Portal showing available Flow runs
To find a specific Flow, a Flow Owner has to either:
- Go into the individual Flows and examine the output of the trigger action step or other action steps, or
Figure 2 - Digging through the trigger action
- Select the “All runs” link, filter on one of the options from the drop down and export the results to a .csv file. Searching through the resulting MS Excel workbook is cumbersome but it will work.
Figure 3 - "All runs" link on the Flow portal
Figure 4 - Filtering Flow Runs
Another Way – Capture Detail in a List
Rather than digging through an Excel workbook or all of the Flow instances, we decided to record information to a list that would help Flow Owners to quickly identify the Flow that has issues. We also extracted and recorded the link to that Flow and wrote it to a Hyperlink column in the list.
The List - “FlowRuns”
Figure 5 - SharePoint list to hold Flow run information
The SharePoint list has columns to record the package name in the Title, the sponsor of the project in the “Project Owner Name”, the Link to the Running Flow instance and other metadata to help to identify the specific Flow.
A couple of things to note concerning the list:
- We had to use the “Send an HTTP request to SharePoint” action in order to populate the Hyperlink column. As of this writing, the SharePoint “Update item” action does not update Hyperlink columns.
- We used a “Single line of text” column type to capture the Display Name of the Project Owner rather than a Person column. We just needed the name of the user who owned the Project to be approved. Updating a Person column using REST requires additional steps to determine the ID of the user and using that value to update the corresponding Person_Column_NameID attribute.
Send an HTTP request to SharePoint Action
There are already a number of blog posts that describe the details about HTTP Methods, correctly referencing lists in the Uri and all of the necessary Headers, so I will just show the details of our implementation.
Figure 6 - Send an HTTP request to SharePoint action
A few notes about the Body:
- The characters preceding “metadata” in these lines are 2 underscores.
- The values for Title, Project Classification, Master Project ID and Project Owner are all Dynamic Content available from a “Get item” SharePoint action configured earlier in the Flow.
- The value for Timestamp is Dynamic Content available from the trigger step, “For a selected item”
- To specify a Hyperlink column (named “LinkToRunningFlow” in this case), use the following syntax to specify the datatype, the Description of the hyperlink and the value of the associated Url
. . .
"Description":"Link to running Flow Instance",
"Url":"Expression to build hyperlink to the running Flow"
. . .
- The Url value is built with a concat() expression using the outputs of Variables and Compose actions
Variables and Compose Outputs
We used the output from Variables and Compose actions as the building blocks for constructing the hyperlink to the running Flow.
Get Flow Start Time
“Get Flow Start Time” is a Compose action whose Input is the Dynamic content, “Timestamp”, from the trigger action.
Figure 7 – Compose action: Get Flow Start Time
“Workflow Instance” is a Compose action whose Input is built by entering the “compose()” function into the Expression builder.
Figure 8 - Compose action: Workflow Instance
Link to Running Workflow
“Link to Running Workflow” is a Compose action whose Input is built by using the “concat()” function in the Expression builder.
Figure 9 - Compose action: Link to Running Workflow
Contents of the concat() function
Output from the concat() function
The resulting hyperlink is in a format similar to the one below and will take a Flow Owner directy to the running instance of the Flow in question to begin troubleshooting.
We placed the “Send an HTTP request to SharePoint” action right after the Flow passed all validations and was successfully placed in the Draft state. This placement assures admins that there will only be one entry written per running Flow.
Figure 10 - Placement of the HTTP action
As Flow matures, I suspect that Microsoft will enhance the Flow Portal to either include more detail or allow for modifications. Until that happens I hope that this will help Flow owners and users make finding specific Flow instances easier.