Tracking your Flow in your SharePoint list
Very often we will trigger a flow from a SharePoint list, and we need to keep track of where the flow is for the particular list item.
This article is going to explain how to keep track of your flows, from inside your SharePoint list.
To illustrate this, we going to create a small example - we will create a list, and from the list we will trigger a flow.
In the flow, we will send an approval task to a user to approve. This way we demonstrate the following:
- Keep track of the state of the workflow;
- Keep track of the outcome of the tasks in the workflow.
What do we need to track
We would like to track the following:
- Status of the workflow - this is what state the workflow is in;
- Results of tasks - so we need to capture:
- Who completed the task;
- Date/Time the task was completed;
- Outcome of the task (approve, reject etc);
- Comments;
- Any other fields captured in the card.
Example
Start by creating a new list
Select "List" from the "New" menu
From our list, we should create a flow
Select "Create a flow" from the Flow menu
Choose the template "When a new item is added in SharePoint, complete a custom action"
Choose this flow template
We now will add the "Start an Approval" task into our flow:
Choose Start an Approval action
Add the details of the approval task:
Managers Approval
Save this workflow - now we have created our list, and created a workflow that triggers an approval action.
But our list is not connected to our flow at all, so how do we do this?
Extending the List
We have to add a set of fields to our list, to keep track of what is happening in our flow.
Add a Status Column
First we add a new column, a Status field to our list. So start by adding a Choice field to the list:
Add a column, choose Choice
Call it "Status", and our 2 states are:
- Managers Approval
- Completed
Add Status field
This will hold the current state of the workflow.
Keep track of the task
To keep track of the task, we should add the following fields:
- Approver - user who completed the task;
- Approved Date - Date/time the task was completed;
- Decision - the decision made;
- Comment - the comment left by the user.
So let add the 4 fields:
Task fields
Now we have all the fields to keep track of the status of the workflow, and the result of task.
Lets wire up the workflow
The only item left to do, is to get our flow to update our list. So let return to our flow, and add the an "SharePoint -Update item" action after the trigger:
Add Update Item action
Set the Status Value to "Managers Approval", as this is the next item in our workflow that is going to happen:
Set the Status to "Managers Approval"
Now we will record the details of the approval task in the list, so add another "SharePoint - Update item" action after the approval task.
Then set the Status to "Completed", and the Approver Claims, Approved Date, Decision, and Comments from the properties of the "Manager Approval" action:
Update the list with the results of the Approval Task
Our SharePoint list and workflow are now connected, and we can see the status of the workflow from the list.
Completed workflow
Lets test
Now comes the fun part - add an item into our list:
Add an item
The Status column should update, showing that the "Manager Approval" task is in action:
Status column updates
In our inbox, or flow app, you will receive the task:
Task from Flow
Complete the task, by approving it, and enter a comment:
Approve the task, and enter a comment
Check your list, and you will see the Status is "Completed", and the approver, date, decision and comment is updated in the list:
A good hint is to add view to list for the different status, so it is easy to keep track of where the workflow are for all list items.
*This post is locked for comments