Lazy Approval with SharePoint – approve task via email part 2

So at this point, you should have a document library that accepts emails.

We need to hop into Sharepoint Designer to set up a workflow that sends out an approval task to employees.  In this example, I have set up a workflow on my IT site in my site collection (this is where i play).  It is a very simple list workflow with one task in it….”Start Approval Process”.  NOTE:  this is only available in the enterprise license of Sharepoint.  You may create custom approvals in other versions of Sharepoint.  The important thing is that it is a task content type (either infopath or native task form).

For this excercise, I am using Sharepoint Enterprise, so the approval is a built-in template.  I created a workflow on the “Shared Documents” library.  I used the “Approval – Sharepoint 2010” template and called it “Testing”.  I set this as a manual start only, but you could set to start on item creation or change as well.

Next, I edit the workflow and add one task….”Start Approval Process”.  This allows me to specify a recipient for the approval, which in turn creates a task item in the task list specified in the workflow settings.  I also clicked the default workflow name and gave this task a unique name “DocApproval”.  This isn’t neccessary, but it looks better when the emails get sent out.

One more thing to note is the task list assigned to this workflow.  In this example, a list called “Tasks” is the list to which the workflow will put the approval tasks.  This name could be different or contain spaces.  Take note of the list name, though, as we will be extracting the list GUID.

In your workflow editor, you should see something like the image above.  I set myself as the approver, because it just makes it easier to debug.

Next, we need to dive into the approval step created by this template and edit the email that automatically gets sent out.  Click the “DocApproval” task (or whatever you called it), and you are brought to the customize task process page.

What we want to do here is set the email for the individual task processes created by this workflow, so we will click the link for “Change the behavior of a single task”.  You will then be brought to the “Task Behaviors” screen.  In the “When a task is pending” section of this screen, you will see a section of code that sends an email to the “Current Task:Assigned To”.  Click this link to get to the contents of the message that will be sent.

When clicking the link, you will see the “Define E-mail Message” dialog box:

I added only one line to this auto-generated email…”ACCEPT or REJECT via email”.  These are the links to allow a user on ANY DEVICE to approve through a regular email system.   How were these links created?  Let’s dive into the ACCEPT link to see how I constructed it.

When you click the edit hyperlink button on this dialog, you can set display text and the address.  I simply put APROVE for the display text, but the address is the tricky part.

CLICK the elipses next to the Address to edit the details:

Let’s take a look at what this link is going to do.  First, the MAILTO is an instruction to create a new email message.  All email clients know how to work with this, as it is a standard.  The first parameter is the recipient of the email (‘sharepointsite@domain.com’).  Next, in querystring format, the subject.  The subject is the ONLY THING WE WILL USE, since the body of the e-mail can’t be set through this function.

The subject is going to contain 4 main peices of information: 1) the command, 2)the list id, 3) the task item id and 4) the site from which the approval came.   With these four peices of information, you pretty much have all the info you need to approve the task automatically.  This approval will be done with a Visual Studio workflow (part 3).

All of these “variables” we are putting in this link come from common lookups found in the Sharepoint Designer, such as [%current task: id%], [%workflow context: current site URL%], and others.  The command (first) could be anything you define.  I chose to use APPROVE and REJECT.

The one wierd thing here is that I am setting a GUID to the task list this is associated with.  The reason for this is the GUID will be more reliable than accessing the task list by name (like “Approval Tasks” or “Tasks”).   The GUID for the task list associated with your workflow can be found by going to your task list, click list settings, then go to target audience settings.  The GUID is in the URL for that setting.  Remove the brackets before adding to your modified task email.

Ultimately, the purpose of this whole email thing is so that when a user gets an approval task via email, they now can be on any device (like an iPhone), and simply click the link for approve or reject in the email and send send the email to approve.

Now that we have setup the library, the email settings, the approval process in sdesigner, we are ready to move on to the last step in this process…making the Visual Studio workflow and deploy it to the site.

Part 3:  https://realworldsharepoint.wordpress.com/2012/06/28/lazy-approval-with-sharepoint-approve-task-via-email-part-3/

Advertisements

2 thoughts on “Lazy Approval with SharePoint – approve task via email part 2

  1. […] Post navigation ← Previous […]

  2. […] Post navigation ← Previous Next → […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: