Thursday, August 11, 2016

How I did “Lazy Approval” on SP Online

The ability to approve or reject a task in SharePoint via an email is known as Lazy Approval.

I was asked to incorporate Lazy Approval as part of our Travel Request solution after a task has been assigned to a Trip Approver. A Trip Approver is a person selected when completing a request to go on a trip. Lazy Approval also allows the approver to approve on any device.

In creating a Lazy Approval, I used the following applications; SharePoint Designer, installed locally on my laptop, free “E-Mail Services” app added from the Office 365 app store. One cannot email from/to a list or a document library on O365 (can only be configured on premise). Please see the section “Email enabled lists and libraries“, for SharePoint Online sites on – http://ift.tt/2aZFIAU.

I had installed a stable third party free app that allows me to email to one list or library per site. E-Mail Services consists of a set of services that handles e-mails within Office 365. It must be said that you may not want to use this app if you are dealing with super sensitive data.

E-Mail Services allows you to transfer e-mails from any mailbox to any list or document library in SharePoint Online. This service brings e-mail enabled lists and libraries to Office 365. Incoming E-Mail is available as a free, fully featured plan with 100 e-mails per month included. If you need more you can choose from a series of plans. For more details please visit http://ift.tt/2bk8a4l.

Moving forward, I created an announcement list named “LazyRequestsAnnouncements” to receive and the handle the emails redirected by the app. After that, I configured the app for the site and the announcement list. I created a site workflow named “LazyRequestsAnnouncements” to listen for an email and perform an action. The action being, when an email contains the word “Approved” the associated task list is updated as approved and vice versa.

How do the user approve or reject via email? This part is after a task is assigned to an approver. The approver would action a task by clicking the “APPROVE” or “REJECT” link (not replying or forwarding) embedded in the task email. They should also not alter or replace the subject of the task email. This is because the subject is set to the task name which is also a unique reference.

 1.    Create the Announcement List

  1. On the site where you want to add an app, go to Settings Office 365 Settings button and then click Add an app.
  2. On the Your Apps page, do one of the following:
  • In the search box, type “Announcements” to find Announcements
  • Click the Announcements app to add it
  • Leave all the default fields as they are

 

2.    Install the Email Service App

  1. On the site where you want to add an app, go to Settings Office 365 Settings button and then click Add an app.
  2. On the Your Apps page, do one of the following:
  • In the search box, type the name of the built-in app you want to add
  • Click the app to add it, and then provide any required information.

 

3.    Configure the E-Mail Services to receive emails

Go to the E-Mail services App, Under Incoming E-Mail, click the “Subscription and settings” button. This will take you to the Incoming E-Mail settings showing;

  1. Your configuration redirect E-Mail
  2. Set the SharePoint list or document library the incoming emails should be saved to
  3. Edit your field mappings
  4. Additional settings

This is shown below in Figure 3.1.

Figure 3.1: E-Mail Services

 

In the travel solution, I copied the redirect email address for later. In the above window, I selected the list within the SharePoint site. I mapped the E-Mail message fields (Subject and Body) to the SharePoint columns (Title and Body respectively). You don’t need to worry about anything else. Make sure you save your changes. That’s it you’re done.

 

4.    Creating the Approved/Reject Link

Now to create Lazy Approval, click the link for the “Assign a Task…” in your workflow. Under the heading Task Options, we are interesting in the open email editor for the Task Creation and Task Overdue emails. You would do the same for both email options. Figure 4.1 shows the Assign a Task window and the email editor buttons under Email Option.

Figure 4.1: Assign a Task

 

For the Task Creation, Click the “Open email editor” to access the contents of the task email. In the “Define E-mail Message” dialog window, you can see the contents of the email. Type APPROVE and REJECT. As the words suggests, the formal will approve a task via an email and the latter will reject the task via an email. This is shown below in Figure 4.2.

Figure 4.2: Define E-mail Message

Now to turn the words APPROVE and REJECT into links that a user can click on to send an email to approve or reject the task depending on which word they click on. To do this you should highlight or select the word APPROVE and click the globe link button to add or edit a hyperlink.

Figure 4.3: Edit Hyperlink (for APPROVE)

 

Next, Click the ellipses to access the string builder. Here you would insert in the Name field, the email address link copied earlier from the configuration tab, in the "Your configuration redirect E-Mail” section of the E-Mail Services app. You would assigned a subject and body for the email.

Figure 4.4: String builder (for APPROVE)

 

I’ve made the email subject matches the Task Name from the “RequestsWF” workflow (which is the Title field renamed to Reference). I also use an URLEncode website to help with the syntax for the email. This populates the body with the “Purpose of Trip”, and the “Trip Approver” fields from the Requests list and the relevant spaces and characters so that it is presentable.

As with the APPROVE link, you would do the same for the REJECT link, changing the word “Approved” to “Rejected” in the string builder. Now the task email has hyperlinks in it to approve or reject that particular task via email. You can say the whole task process looks a little user friendly.

5.    The Task Email

Below is the email sent and received to the task assignee through the Assign a task action constructed in the RequestsWF workflow. The task assigned title which is the subject of the email is the Reference column of the Requests list (renamed from Title). The Reference column is made up of the current user logged in dash created date (in ISO Formatted).

This Reference is also the Task Name which is the blue link in the actual email. Clicking this link will land you on the page of that particular task.

Figure 5.1: The Approved email

 

The approver or task assignee should not Reply, Reply All or Forward the email. Why? Because Reply and a Reply All will start the subject of the email with a “RE:..” and a Forward will start the email with a “FW:..”. This will not work in Lazy Approval because the email subject should match the Task Name. I am using the Task Name as a unique reference to perform various operations.

Figure 4.5 shows the email as it should be with the correct title after the user clicks the APPROVE (or REJECT) link.

Figure 5.2: The Approved email

 

Above is what the email to approve a task looks like. Likewise, the email to reject a task looks the same except it starts the word “Rejected Request…” in it. The user should just Click the Send button and nothing else really. They can type additional information in the body but must not remove the words “Approved” or “Rejected”.

After the approver sends the email, it is delivered through the E-Mail App to the announcement list created earlier. There is a site workflow in the background to handle the email delivery and update the “RequestsWF Tasks” accordingly.

As stated earlier, the Task Name associated with a request is the same as the email subject. This is then mapped to the “LazyRequestsAnnouncements” Title SharePoint column.

6.    LazyRequestsAnnouncements workflow

Firstly, the site workflow is a 2013 workflow linked to the “LazyRequestsAnnouncements” announcements list. This workflow was started manually and is always running.

The first stage of the workflow is “Waiting”. The workflow waits for an item to be added in the announcement list. Remember this item is the lazy approval email (constructed earlier) sent to the announcement list. When the item arrives, a unique variable is assigned to it named “related item”. This can be given any name but I decided to leave it as default.

Figure 6.1: The Approved email

Then I set a local variable named “AnnoucementTitle” to the same as the “RequestsWF Tasks” Task Name when it is equal to the Title column of the email received in the announcement list named “LazyRequestsAnnouncements”, where each email has a unique ID differentiating it from all other emails (before or after).

Figure 6.2: The Approved email

 

In the UpdateTask stage, if the body of the email received in the “LazyRequestsAnnouncements” list contains the word Approved then we want to use the Update List Item to update the “RequestsWF Tasks” list fields. The Task Outcome is set to Approved and the Task Status is set to Completed where the Task Name is the same as the Announcement Title.

Else, if the body of the email received in the “LazyRequestsAnnouncements” list contains the word Rejected then we want to use the Update List Item to update the “RequestsWF Tasks” list fields. The Task Outcome is set to Rejected and the Task Status is set to Completed where the Task Name is the same as the Announcement Title.

This is shown in Figures 5.3 and 5.4 respectively.

Figure 6.3: Update List Item

Figure 6.4: Update List Item

The last and final stage is “Incorrect”. If Task Name and Announcement Title does not match it is logged, the task is either approved or rejected and the process starts again by the going back to the Waiting stage as shown below in Figure 5.5.

Figure 6.5: Incorrect stage

To conclude, this site workflow is always running. The user do not know anything about this. They just have to Click APPROVE or REJECT as appropriate. That’s it, you’re all done.


by Larry Saytee via Everyone's Blog Posts - SharePoint Community

1 comment:

  1. Hi
    Thank you for sharing.
    I am trying to implement the same in my tenant and did not get the screenshot which you attached on this post. So please advice.

    ReplyDelete