Workflow Lazy Approval
What is lazy approval? It is the ability to reply to an approval email with the word “Approved” or “Rejected”, without need for the approver to go to a site in SharePoint. With the mobile workforce, this is a feature that is in high demand, for people to quickly be able to read an email and approve or reject instantaneously. In this blog post, I’ll show how this can be done with SharePoint 2013, specifically with SharePoint 2013 workflows. This is only an on premises solution, and is NOT available in Office 365, this specific solution also cannot be done with a SharePoint 2010 workflow. Office 365 does not have the functionality that SharePoint on premises has, where you can turn on “incoming email”. On premises, this is something that your SharePoint server admin had to have set up at the server level.
Incoming email can be used for Document Libraries, Announcement lists, and Calendars.
When you turn on incoming email in a list or library, you assign it an email address. In this solution, this will be useful for lazy approval, because the approval email that they send can arrive in a SharePoint list, and then a workflow can go out and complete the associated task automatically.
The components of this solution:
- A request form that needs to be approved. My example is a very simple travel request form. This has been created as a custom list.
- A task list. In this example, I’m just letting the workflow use the default “Workflow Tasks” list on my SharePoint team site.
- An Announcement list. When I created this list, I used the “Announcements” list template. I named this list “Approval Email”.
- Approve Travel. Running when new items are created in the travel request list (1)
- This is a site workflow, and will wait for emails to arrive in the announcement list (3)
Some of the trickiest workarounds we’ll be dealing with in this solution are the lack of list relationships. First of all, task lists are inherently not related anything. There is no lookup field that connects a task to the thing that is being approved. So we’ll have to use the task name as a unique field. Also, when we receive incoming emails, they will not be related to anything either. Another challenge is that when you create a workflow ON the list where the emails are arriving (3), the arriving items do not trigger a workflow. This is why our workflow will be triggered in a different way. I’ve heard about people making configuration changes on the server or doing something with PowerShell to make this work, which would also make it work in 2010, but this solution is NOT going to make you do server changes.
My associated video:
SharePoint Power Hour Episode 97: Workflow Lazy Approval
Here’s how to build this.
- On the approval email (announcement) list (3), go to list settings, and click Incoming Email Settings. I used the following settings. In this case, I only need simple information as to whether or not something is approved. The subject and body of the email will automatically fill in the Title and Body fields in the list. I don’t need any email attachments, and I don’t need the original *.EML email file. Also, I chose the email security policy to accept messages based on permissions. That way, I can let only a certain group of approvers have Contribute permissions on this list, and no one else. That way, I won’t get random other people trying to send email here, or approve things they’re not supposed to approve.
- Create the SharePoint Designer workflow, Approve Travel, on the list of travel requests. Set it up to run when new items are created.
- For the first action, use “Assign a task” or “Start a task process”. I usually prefer the first one for several reasons, one to point out for this solution is that the task name will be identical for all tasks that get assigned for any given travel request. I named my stage Assign Task. Click the blue this user.
- For the participant, pick a user or group. For the task title, pick just the ID of the current item. Yes, in real scenarios that is not a feasible task title, but we will make this more complex later as we go along.
- Expand Email Options, and click the first Open email editor button, for the task creation email.
Don’t forget, you may want to modify the task overdue email in the same way, if you use these and if you want your users to have lazy approval links in these emails as well. Notice it in the screenshot above.
- This standard email tells the task assignee some info about what they’re approving, with a link to the task and a link to the item needing approval. For a scenario where you want the approver to have all of the info they need, right in the email, it will help to insert some additional fields. You could insert every field from your travel request if you wanted to, but for demo purposes, I only inserted the start and end dates of the trip. This is also where we are going to insert links to let the approver click to do the lazy approval. Type the words Approve via email, and Reject via email. We will create the hyperlinks next, but here’s the general idea:
- We will put all of the info that we need into a mailto URL. Here’s the mailto Link Syntax guide that I found. Select the word Approve, and click the hyperlink button (the little globe). Click the little ellipsis next to the Address box, to bring up the string builder. For now we’re going to keep this super simple, and only put the ID of the travel request in the email subject. We’ll get it running that way, and then we can get more advanced with various string actions. What email address did you create at step 1? We’ll use that here.
mailto:email@example.com?subject=[Current Item ID]&body=Approved
- Click Ok twice, and then select the Reject text, so that you can make this a hyperlink also. Repeat step 7, and the only difference is that instead of Approved, the mailto syntax will have &body=Rejected
Click Ok on all screens.
- This workflow is going to be pretty simplistic, and of course in the real world you will have other things going on in it. For example, I’m just going to log whether the travel was approved or not, but realistically you’d be using the Send an email action to notify people that something has been approved or not, etc. Add two more stages to the workflow, call them Approved and Rejected. Here’s the whole thing:
- Finish out the Create the Approve Travel workflow as above, and publish it. Make sure it’s set to run when a new item is created.
- Create a new SharePoint 2013 Site Workflow, and call it Wait for Email. The important thing to remember about this workflow is that it will be running and perpetually looping each time an email arrives in the Approval Email list (3), so each time you change it and publish a new version, you have to go terminate the currently running one, and start it all over again. This will mostly just happen during testing and the workflow creation process. Once it’s being used, it will just run and stay running.
- For the first action, add Wait for event in list item. If you are not using a SharePoint 2013 workflow, you will not have this action available. No, I’m not sure how you’d do this in 2010. I named this first stage Waiting. Click the blue this item event.
- Choose Event: When an item is added, and for the list choose Approval Email. Click OK. This means that when a new email arrives in the approval email list, this action will be triggered on the already running workflow, and will also give you this variable called related item, which is the GUID of the item that was just created. (note that GUIDs are new to 2013 workflows and are not the same as the ID of the item)
- For the next action, choose Log to History list. This step is not required for this workflow to function, but gives you some reference info when troubleshooting. Just log that the email arrived, and what the GUID is. On the string builder, click OK.
- The only data that we have to go by in this arriving email is the info in the subject and body. To start off, we need to be able to match the arriving email with which task it needs to complete. In this simple example so far, we have created the task and the email to both equal the ID of the travel item being approved. After logging which item arrived, create another stage called Complete Task. The Waiting stage will just go straight to the Complete Task stage for now. Here’s the whole thing, and I’ll show you what was done in each action. Note that the “contains” that I used is case sensitive.
- Here’s the Set Workflow Variable action (the 3rd one). Set an integer variable called TaskID to this, which is the ID of the task WHERE the title of the task is equal to the email subject of the email that just arrived. This TaskID can now be used in several other places in the workflow, to reference the task.
- Here’s the Approval Email: Body (the IF statements). Basically, get the Body of the email WHERE the GUID of the item in the approval email list matches the related item variable.
- The Update item in Workflow Tasks is the Update item action. Basically, set the status to completed and outcome to Approved for the task WHERE the ID of the task equals the TaskID workflow variable. Whew!
- For the Else if part of the workflow where the rejection is, you can just use copy and paste in your workflow to copy the IF statement and also the update list item action. Then, all you need to change is the word approved to the word Rejected.
- Notice that the last Transition to Stage is to go back to the beginning, to the Waiting stage. This way, the workflow will be waiting again for the next email to arrive. Once your whole workflow looks like step 15, Publish it. Go to your SharePoint site, and go to Site Contents. Click Site Workflows.
- Click the name of your Wait for email workflow, to kick it off. Then you will see it listed under My Running Workflows, in the Waiting status (because that’s what we called the first stage).
- Okay, time to try it out and see what it can do so far, BEFORE making it more complicated. Go to your travel request list and create a new request. I think I’ll go to Hawaii.
- Wait for the task assignment email to arrive. I simply assigned mine to myself for now. This could take 5 minutes or so, because these run based on a timer job on the server. Here’s the email
- Try the Approve hyperlink. See that it opens up a new email. Click Send, without changing anything. (This can also be verbiage that we can add to the task and the email, telling users not to change it just click Send.)
- Keep an eye on the Approval Email list on your site. The email will arrive here, which will trigger the workflow to complete the associated task (in Workflow Tasks), which will then display the word Approved next to my travel request for my trip to Hawaii (Travel Request list). You can change your view in the Approval Email list, to include extra columns, such as Body and E-mail Sender. The Title and Email Subject will have the same value.
You may want to try doing a couple of these. Also, take a look at the still running site workflow from step 20. Click on the Waiting status, to see the log of what’s happened so far. If your workflow says “Suspended”, that means that there’s a problem, so click End Workflow. Then once you fix/tweak and re-publish (like I have done many, many times in figuring this out), you just have to remember to do step 20 again (start it again).
- Okay, so now that you see that it works, you will probably want to make some tweaks, such as to have a better email subject, or to even make sure that the person sending the approval email is actually the same person that the task is assigned to. This is where it can get really tricky. In SharePoint Designer, open your Approve Travel workflow to edit it. Open your Assign a task action, so that you see the screenshot in step 4. Click the ellipsis next to the task title. I’m calling mine Travel Req: # Approval. Click OK. (I’m using the term “approval” as a generic term referring to the approval process. The actual outcome is approved or rejected, and it will be in the body.)
- Now the task will look nicer, but now we need to make the email subject still match the task name so that step 17 will work correctly. I also use the URLEncode URLDecode website to help me with my syntax. I’m also throwing in some info about who is going and where they are going.
With the above syntax, when the approver clicks the Approve hyperlink in the email, it will create this email, and they just need to click Send.
- If you want to check the name of the email responder to make sure it’s the same as the person who the task is assigned to, this adds more complexity, but can be done. Here’s the new, more complex workflow, with logging added as well:
- Here’s how to do the comparison between the person sending the lazy approval email and the person the task is assigned to. This is in the IF statement inside that first stage transition.
That’s it! There are many different ways you could slice this, but I tried to break it down to the simplest way. If you need to extract specific info from within the body or subject after the email arrives, there are several utility actions that can be used:
Also, there’s the possible complexity you may have when using the task process that involves more than one approver. All task names are the same for that one travel request when that happens. One thing you can possibly do, would be to run a workflow on the task list, so that when items are changed, and the status is equal to completed, it actually changes the task name. Another idea: When you send the lazy approval email, there is no task ID available to include in it, but there is a task URL, which will inherently contain the unique ID of the task. You could include that in the response email, and then use the utility actions to extract that ID, like extract substring from index of string. For example, my task url might be http://site.contoso.com/lists/tasks/dispform.aspx?ID=# so the index would be 54, which is where the ID is. As you can see, it could get much more complicated. For troubleshooting, don’t forget steps 21 and 25.
Again, here are the requirements to be able to do this:
- SharePoint 2013 on premises
- Incoming email is set up on the server
No, I don’t know how this could be done in Office 365, and yes, this type of solution is possible in SP 2010 I’ve heard, but there’s something you have to do on the server to make the arriving email actually trigger a workflow, since it won’t by default. I’ve never done it.
Laura, this is an awesome solution! I can see the need for this especially for mobile users.
I want to point out that while Office 365 does not have native capability for emailing to a SharePoint list, I found this great app that does have this capability called Email Services (http://www.office-cloud-services.com/en/index).
I’m using it for my GTD Dashboard solution. I have no affiliation – I just think it’s great. And it’s free for the first 100 emails per month. For low volume users it’s a great deal.
That Email Services app is awesome, Wendy! The perfect answer for Office 365! I tried it, and it even lets you map certain fields in the email to columns in SharePoint.
If you’re looking for a way to process incoming email on Office365, take a look at using Azure Logic Apps. I have a blog post on it: http://sharepoint-community.net/profiles/blogs/email-enabled-sharepoint-lists-on-office-365. I’m @starxed on Twitter if you want to discuss it further. 🙂
Thanks for the PowerApps reference, Paul! Great info!!
For incoming email list, did you have to do a separate configuration for email body to show in body column in the list?
Hi Anil, no that’s not a separate configuration. That’s automatic.
Thanks Laura Rogers, thanks Wendy Neal.
Great Post! Thanks Laura.
The images in the post are broken links. Can you look into this?
Hi Jane, thanks for letting me know! All fixed!
Hi Laura, i have one question: i have a document which has to be approved with 7 consecutive approvers, can it be, your approval workflow, also the solution? thx pavel
Laura, I am in the process of building a solution for a business process and this instruction has opened the doors for me! Eternally grateful!
Hi Laura, can you provide the the soft copy of the workflow scripts that you have done so that I can try them out.
Hi, sorry, no I don’t have those anymore.
I followed your instructions exactly and checked multiple times, however, my workflow still is not working .The submissions works, the email response works, but then my workflow errors out when checking to see if the email task is approved or rejected. I think it has something to do with the workflow task ID. The email subject lookup to the GUID appears to be failing. Any recommendations on how to get this to work?
can You share the Visio part? i destroyed my pc with finding the proper visio version 🙁
may be we can solve it together
Hello, I am not sure what Visio part you are referring to. The workflow is in the sharepoint editor. The site workflow is what is not working for me.
FYI I found my way around the issue I was having. I had to change my email body response column in sharepoint to not be enhanced rich text, but only rich text since my email sends via HTML format.
Add logging to your workflow, and visually compare the values that you’re logging. Variables, etc.
Thanks for your post. from the above example, I have send a email notification to receipts once its approved via email.
can you please help on this.
did you menage the visio part? i can help You with the notification.
Sure just add a “send email” action at the end of the workflow, or you could even just use good old SharePoint alerts.
I have the requirement in my project ,thanks for the article and the example with pictures.
But one thing that I did not understand about Email Subject ,
how the email Subject column can be added?
is this custom column or existing site column ?
or only it will appears after the incoming email configuration ?
how the email subject sits in to this column once the email arrives ?by design?
please explain ,I am confuse
Can you please explain ,how to get that email subject column?i did find in on premise as well.
Read step one.
yeah I got it Thanks Laura.
Thanks for the solution that really helped me in my project.
and i am also have an issue with the “Modified By” column value after workflow updating the task list .
the scenario is:
I am sending an Approved or Reject email from outlook to Announcement mail box,
and that will create an item in Announcement list ,
when item got created “Modified By” name is showing my name ,that is expected behavior ,
but after updating or while updating the Workflow Tasks “Modified By” column changed to “SharePoint App”
I am not using any App Step in my Workflow.
please help, because I am using Modified By column in Another application.
I am not sure what went wrong, even our Admin is not helpless.
if I get any help from your side it would be great.!:)
hello Laura please help me i am stuck here …. my workflow is giving me an error of “The e-mail message cannot be sent. Make sure the outgoing e-mail settings for the server are configured correctly” i have configured the Outgoing Mail settings also , but still facing the error ….Please Help me out
Do SharePoint alerts work at all? If they don’t work, then the server isn’t set up correctly, and its not a workflow issue.
Hello Laura ,
alerts also are not working …can you please help me out how to troubleshoot this issue …i m stuck on this from last 2 weeks , i was working on lazy approvals but this problem stucked me in middle please help me out .
i am a New on Sharepoint following you n your channel for share point learning. Can you please give me some guidance.
Are you the SharePoint server admin? Outgoing email is something that has to be set up on the SharePoint server, in Central Administration.
Yes mam , i am the admin also & i have configured it also , but it is showing me the same error , what should i do please give me some solution.
Not sure what version of SharePoint you’re on but TechNet is the reference you need for server config https://technet.microsoft.com/en-us/library/cc263462.aspx
i am using sharepoint 2013 server enterprise vesrion … installed few days back only , but the issue is coming in the mail thing which i tried to solved many time from diff solutions …. still i hvnt found the solution … via telnet smtp is firing email but via sharepoint itis not , why so .. please help
I have no idea.
Thank you this worked very well for me.
The ID in the title is a stroke of genius. I actually kept the normal title and ID so that you can do multiple approval levels per ID as long as each Title is unique. Possibly you can become unstuck if approval workflow is kicked off again, but its a very easy to implement solution and can fit into existing approval workflows with minimal fuss.
The only other change I did was make the email list workflow a “list workflow” rather than a “site workflow”, which starts whenever something new is added to the library.
Thank you once again.
I know article mentions that : Incoming email can be used for Document Libraries, Announcement lists, and Calendars.
But still searching for a way for doing same thing for a custom list.
Please share if you have discovered any workaround or there is any new updates in this matter.
Nice article. I have a question, will this work for Infopath Forms?
Sure. Your form technology / product is irrelevant in this solution. But this is pretty old, all done with SharePoint Designer, which is circling the drain just like InfoPath.
So is there is a better or alternative easy solution?
Yes. Microsoft Flow. It has lazy approval built in on the approval actions. This post you’re reading is really, really old.
Hi, is it possible to do Microsoft Flow for Infopath forms using Forms Library?
sorry for this question, but: did You presented this tool in Your channel already? If not, can You give us some hit how to find it and set it?
When you’re creating the Flow, and picking the name of a list or library to connect to, if you don’t see yours in the list, just click “custom…” and type the name of your list or library. That way, if it’s something like a form library or contact list that doesn’t show there, you can still connect to it.
Thanks, I have tried MS Flow, it is really useful, but due to MS Flow Form Library limitation, I had to duplicate my Form Library to a custom list in order to trigger my flow.
I know that this is a very old article, but I am using sharepoint and have a need to do multiple approvals. I saw at the end of your blog how you suggested to do this and watched your video on this. I have made each task a separate task, but the approval will only work for the first approver. When the second approver sends the approval email it is seeing the old task even though it has a strikethrough and has been ran already and states that it is not the correct approver. I don’t understand how to make the task unique so that it will work correctly. Any help would be appreciated.
You didn’t mention what version of SharePoint you’re using. If you’re using SharePoint online, you won’t want to do this the very old way that I was doing in this post.
Kindly advise, any workaround to do lazy approval in shareportin 2010
i’m facing an issue with the incoming emails as I didn’t receive them on the announcement list, any ideas please.
Thanks in advance!
That’s most likely an issue on the server side, so you’ll have to let your server admin know that they should configure outgoing email correctly. I don’t remember that procedure, I haven’t done it in 10 years.
Is it possible to apply multiple lazy approvals?
I don’t know, this post is 5 years old and I don’t use that version of SharePoint or SharePoint Designer anymore.
I have not getting the Word “Approved” under Approve Travel Workflow column in the Travel Request list, The workflow worked fine, I also got an email to approve or reject a request, I clicked on Approved but still the Approve Travel column in Travel Request column highlights “Assign a Task” – Can you please guide how the stage name reflects in the Workflow column in the Custom List
I don’t know, this post is 5 years old and I don’t use that version of SharePoint or SharePoint Designer anymore.
I Have two approval column.
1. Test Workflow (created by sharepoint designer 2013)
2. Approval Status (from Versioning Settings content approval)
In my Test workflow, the status has been APPROVED .
I want to control Approval Status column base on my Test Workflow. So when Test workflow is Approved then Approval Status should be Approved too.
Any suggestion for my case?.
Thanks for helping me.