Today, I want to talk about very useful feature provided by SharePoint workflows called ‘Lazy Approval’. This feature allows you to get input from approvers or users via email. Approver can ‘Approve’ or ‘Reject’ requests without logging to the sharepoint site. It also enables users to fill form and submit data into SharePoint list through email.
To see Lazy approval in action, let’s Consider a scenario where list of users will be sent an email which will ask them to enter number of pizzas they want to eat. Each user will respond through an email. Then, the system must calculate the total number of pizzas requested by all the users.
We can implement this using Lazy approval in conjunctin with ’Request Data’ action of Nintex workflow. ‘Request Data’ action allows you to receive input from set of users. Once the input is received, we can perform operation on data received.
Brief summary -
1) Create a list in SharePoint. It will have a people picker field to store list of pizza eaters.
2) When item is added, a workflow instance will be created. This worflow will send email, with a small form asking No. of pizzas they want to eat’ to all the pizza eaters.
3) Once the response is received, workflow will calculate the total number of pizzas to be ordered.
Create a list in SharePoint
1) Create a SharePoint list named ‘Pizza Hut’. Add a people picker field ‘Pizza Eaters’. Enable it for multiple selection and set it’s ‘Show field’ (Under column settings) to ‘Work e-mail’.
Create another field of type ‘Number and name it ‘Total Number of Pizzas Requested’.
Add ‘Regular Expression’ Workflow Action
2) Create a Nintex workflow using ‘blank’ workflow template. From ‘Operations’ tab, drag and drop ‘Regular Expression’ action. This action will parse and add all the email Ids into ‘EmailListCollection’ variable.
Create 4 variables as shown below.
|Collection||This will store email ids of all the pizza eaters|
|Single line of text||While iterating through email list collection, each emailId will be stored in this variable.|
|Number||This will store number of pizzas requested by each user.|
|Number||Total number of pizzas requested.|
Now, configure ‘Regular expression’ action as -
Pattern – ;
Operation – Split
Input Text – Insert reference of ‘Pizza eaters’ SharePoint field.
Store Result in – ‘EmailListCollection’ variable.
Add ‘For-Each’ Workflow Action
4) Drag Drop ’For each’ action under ‘Logic and Flow’ tab. This action will add ‘for-each’ loop which will run for each emailid present in ‘EmailListCollection’ variable.
Configure this action as shown below.
‘Target Collection’ is the collection you want to iterate which is ‘EmailListCollection’ and each emailId will be stored in ‘CurrEmailId’ var.
Add ’Request Data’ Workflow Action
5) Next step is to send email to each emailId within ‘EmailListCollection’. For this, drag and drop ‘Request Data’ action (under ‘User Interaction’) within for-each action. Pls see below -
Configure this action. set -
Collect Data from – ‘CurrEmailId’ var.
Content Type – Choose ‘Create new’ and name it ‘PizzaHut’. Add a field of type ‘Number’ and call it ‘Number of Pizzas Requested’. This will add a field in the form which will be sent to user via email. Next to this field is a drop down list, select ‘NumberOfPizzasVar’. This workflow variable will store the value provided by user against a field ‘Number of Pizzas Requested’.
Check ‘Enable responses by email using LazyApproval’ checkbox.
Add ‘Math Operation’ Workflow Action
6) Now, within ‘For-Each’ action, drag and drop ‘Math Operation’ action. This action will add all the number of pizzas requested and store it in a variable ‘Total’.
Configure it as below -
This will calculate Total number of Pizzas requested and store it in a variable ‘Total’.
Add ‘Set a Field’ Workflow Action
7) Finally, we just need to set the value of SharePoint List field ‘Total Number Of Pizzas Requested’. So, drag and drop ’set a Field value’ action. This must be added utside for-each loop and configure it as shown below -
Finally, configure your workflow to run automatically whevever an item is added by going to Workflow settings.
Now, Add an item to ‘Pizza Hut’ SP list and. All the users under ‘Pizza eaters’ will receive an email shown below -
All the user who receive this email just need to reply by entering a number of pizzas inside square brackets(circled in image above). Workflow will calculate the Total number of pizzas requested and update the field in list.
After the workflow is completed, your list will look something like this