This tutorial demonstrates how to build a leave request workflow using Nintex Workflow for Office 365 and uses two SharePoint apps; a custom SharePoint list called “Leave Requests” and a Calendar.
For a related tutorial, see "Automate leave request notifications" in the Nintex Workflow for Office 365 help.
Create a SharePoint List
Create a SharePoint List called "Leave Requests", with the following columns.
Note: For background on SharePoint lists, see this Nintex for SharePoint article.
- Leave Type (Choice – drop down menu) with the following selections; Annual leave, Sick Leave, Leave without Pay, Carers’ leave.
- Start Date (Date and Time)
- End Date (Date and Time)
- Description (multi-line textbox)
Create a Leave Calendar
To create the Calendar, click on the Settings icon in the top right –hand corner and select Add an App. Click on Calendar, and call it “Leave Calendar”.
Add a Leave Request Page (optional)
You may want to create a page for the two SharePoint Apps to sit on. This page will display all the Leave Requests made as well as the leave calendar. To create a page, click on the Settings icon in the top right –hand corner and select Add a Page. Call it “Employee Leave”.
To begin, the page will be blank, so you will need to add the webparts for the Leave Request list and Leave Calendar.
Click on Insert in the Ribbon and then Web Part.
In the Apps category, you will find the Leave Calendar and Leave Requests apps. Click on them and select Add. They will be added to the SharePoint page as a web part.
Click on the Page tab and select Save. Your page should look similar to the screenshot below (my calendar and list is already populated with one approved set of leave).
Build your workflow
Navigate to the Leave Request SharePoint list in the Quick Launch menu, click on the List tab and select Nintex Workflow in the Ribbon.
On the Workflow Gallery page, click New list workflow.
Create a Variable
Click on Variable in the Ribbon. This variable is going to store the outcome of the approval task. Call the variable “Task Outcome” and select the type Integer. Click Save.
Add a Send an Email action
Drag a Send an Email action onto the canvas. Double-click to open the dialog box. This email will be sent to the initiator of the workflow.
In the To field, click on the List Lookup icon. In the first menu, select Workflow Context and the Initiator in the second menu.
In the Subject field, type “Your [leave type] request has been received”.
Note: The [leave type] Insert reference is accessed through the Insert Reference column on the right-hand side of the action dialog box.
In the Email body, add a message. For example: “Your [leave type] request starting on the [start date] until the [end date] has been received and has been forwarded to your manager for approval.”
Note: The [leave type], [start date] and [end date] information comes from the Workflow Context section of the Insert Reference dialog.
Add an Assign a Task action
Locate the Assign a Task action in the User Interaction workflow toolbox. Select and drag the action onto the canvas below the Send an Email action. Double click on the action to open the dialog box.
In the Participant field, assign it to the Manager. Type “Administrator” into the field.
In the Task Title field, type “Leave request for…” and then add in “Initiator display name” from the Workflow Context section of the Insert Reference dialog.
Notice the Task Outcome section has automatically defaulted two outcome options - Approved and Rejected. These outcomes will be displayed automatically on the design canvas to continue building the workflow.
Note: You have the option to select LazyApproval in the Assign a Task and Start a Task Process actions. With LazyApproval, reviewers can approve or reject items by sending email replies that contain a valid phrase.
Add a Send an Email action
The next step is to drag and drop a Send an Email action onto Rejected side of the Task action to notify the Initiator that their leave request has been declined. Double-click to open the dialog box.
In the To field, click on the List Lookup icon. Select Workflow Context and then Initiator.
In the Subject field, type “Your leave request has been declined”. And then in the Email Body field, type “Declined”.
Add a second Send an Email action
Click on the arrow on the left-hand side Send an Email action. Click Copy.
Click on the Approved side of the Task action, right-click on a drop-zone and select Paste. Double-click on the action to open the dialog box.
In the Subject, change the word “declined” to “approved”. In the Email Body, change the message to “Approved!!”
Add a Create List Item action
The final action is Create List Item, which you will find in the Libraries and Lists toolbox category. Drag and drop the Create List Item onto the canvas, on the left-hand side (Approved side) of the Conditional Branch.
In the Target List field, select the Leave Calendar. Once a leave request has been approved, the leave dates will be entered in this calendar.
In the Title field, select Workflow Context, and then Initiator. We also want to coerce the Initiator output to appear as the Display Name. Click on the orange fx to the right of the Initiator menu.
Select the Display Name format and then Ok.
In the Start Time field, select List Lookup, and then Start Date in the Field menu. In the End Time field, select List Lookup, and then End Date in the Field menu.
Publish and run the workflow
We’re now ready to publish and run the workflow. Click Publish in the Ribbon and give the workflow a title “Leave Request Workflow”. Automate the start of the workflow, by checking the Start when items are created checkbox.
Close the workflow designer, return to your SharePoint list and add a new item to run the workflow.