Microsoft has introduced Flows that enable development of Workflows for SharePoint Online and more than 50 other services over the cloud.
In this article, we will see the demonstration of Microsoft Flow around SharePoint Online and will deal with List Item Add Event. For this demo, let’s consider we have a Product Catalog List which requires Approval to happen with each new item added.
We have a Product List, as shown below.
Go to “Flow” menu and click on “Create a Flow”.
Here, we have two choices. Either we can use any available workflow template that suits our requirement or we can create a new one from scratch.
For this demo, we will create a Flow using blank template. Go to Flow Site by clicking “See you flow” links.
Click on “Create from blank”. This will launch Workflow Designer.
On the Workflow Designer, select the Trigger.
We can select trigger from any of the available services, as highlighted below.
Provide the title of the Workflow.
Select SharePoint Trigger “SharePoint-When a new item is created” that will fire when a new item is added to SharePoint Online List.
Provide Site URL and List name to setup SharePoint context. Add an action to the Workflow by clicking “Add an action”.
Select approval action by selecting “Outlook.com – Send approval email”.
Select “Approver Email” in “To”, since this “Approver” is a People Field on SharePoint. Workflow designer is intelligent enough to represent each property as a separate field.
Add a condition to the workflow by clicking “Add a condition”.
In the condition, we are check if Approver Approved the Production or not.
If Approved, then send approval email to requestor; else delete the Product and send Email to the requestor.
Choose “Created By Email” field in “To” as it will hold the Email Id of the Requestor (Person added the Product). Choose “Approver Email” field in “CC” to send a copy of the mail to Approver also.
If not approved, delete the Product by choosing action “SharePoint – Delete item”.
In the “Delete item” action, specify SharePoint Site URL and List Name.
Select “ID” token for the field “Id”. This token will hold the ID of the List Item that trigged the Workflow.
After deleting the item, we send email to the Requestor by choosing “Created By Email” in “To” field.
Specify the body of email as desired.
Choose “Approver Email” field in “CC” to send a copy of the mail to Approver also.
Once all the actions are configured as required, save the workflow by clicking “Save flow”.
With this, we are all done and now it is time to test the workflow.
To test the Workflow, add a new item in the Product List. Specify Title and Approver and Save the Product.
Save action will trigger the Workflow that we just created.
As a result of Workflow execution, Approver will get the Email with “Approve” and “Reject” options.
The beauty of this implementation is that the email contains clickable options for approver to submit the approver’s choices from within the email.
Here, Approver rejects the Product.
As a result of this Rejection, the workflow will delete the Product from the List and send an Email Notification to Requestor and Approver informing same.
Product has been deleted from the list
Now again add a new Product to the list that will again trigger the event to execute the workflow
Product has been added
As a result of Workflow execution Approve will get the Email with “Approve” and “Reject” options
This time Approver approved the Product
As a result of this Approval, the workflow sends an Email Notification to Requestor and Approver informing same.
Hope you find it helpful.