In this article, we will see how can we create a two-level approval workflow in SharePoint Designer 2013 workflows.
Let's understand the process first,
The process starts by the initiator, who can apply for a request by entering some details which triggers an email to the approver automatically by notifying them to take action on the pending task. The approver can review it and verify all the details which were submitted by the initiator by clicking on the link that is provided in the same mail trail. If he wants to approve it, he can simply click approve button else if he wants to reject then he can click on the Reject button.
If Approver rejects the request then the request doesn’t process for further Approval and the requestor will get a notification mail in which notifying that your request is rejected. But if the request is approved by the first-level approver then the second-level approver receives an approval mail with the same details that were submitted by the initiator and he can take any action by clicking Approve & Reject button. An approver action notification will be sent to the initiator.
Let’s start and create a custom list named "DemoList". The following columns need to be created- Employee Name, 1stManager, 2ndManager, Start Date, End Date, Leave Type, etc. Now open your SharePoint Designer & click List Workflow and choose your list.
After the naming of the workflow & Select SharePoint 2010 or Select SharePoint 2013 Workflow. And click the ok button.
Kindly select "Find Manager of current user" Action.
Click on this user and select Current Item & Created by & in the output select variable 1stManager.
Same as the previous step again select "Find Manager of current user" Action. Now choose the 1stManager variable and in output 2ndManager as shown in the figure.
Select "Log to in the history list" action. This will be useful for troubleshooting or debugging purposes.
Now Select Action "Start Approval Process on Current list with users".
Select the user whom you want to assign the task, and select variable manager1st as here we want to assign the task to the manager. After setting the user in that respective variable which will be shown in the below images.
Note
I will suggest you assign task to a user who is available in your tenant as we can't assign task outside the domain
Click on Approval (approver) which will redirect to a new window which is given below
Click on Change single task Behavior.
Select set workflow variable action in both places as shown above.
Set to yes in the upper one and set No to in a lower step which leads to the status of the workflow.
Now Log it to the history for logs.
Now select action If value equal value & click on value
In the data source, Select Variables & parameters, and in Filed Source to IsItemApproved
Now click on values and make the value yes after that click ok button.
Choose action Start Approval Process same as the earlier step, current item and user to whom you want to assign the task. Here we will 2ndManager variable.
I will suggest you to assign the task to a user who is available in your tenant.
Now we log the message to the workflow history and click on ok button.
Now Triggered the workflow manually and automatically or when the item is updated as per your requirements.
After that make a step and named it Workflow Ends. Select action Stop the Workflow and log it Workflow Ends at this Step.
Last but not least publish the workflow.
Now we will check our Workflow and output example is given below,
Go into the list and add a new item in the list.
Approver gets a mail like this, in which he has to click on Review "Regarding Leave on 28th of January".
User can Accept or Reject the request.
This is the out-of-the-box mail format that the user will receive when the approver will take any action on his request. We can also change the mail body.