Build One Click Approval into Workflow Emails

I recently received a requirement from a customer who wanted to build one click approval into the email notifications being received around a Purchase Order process.

 

As Purchase Orders are being created in a forms library (although this could work against any list item use case), a SharePoint Designer workflow was created to determine approval routing and an email notification was sent seeking their approval.  When the approver received the email, two links are presented to allow the approver to Approve or Reject the purchase order.

 

Email Notification

 

These built in links call a Toolset provider to update the status accordingly and then the connection redirects the user to their dashboard in SharePoint.

 

Here are the easy to follow implementation steps:

 

1) You will need to create an External Data Provider (for more information on creating an EDP consult other articles on the Community site).  Create your connection needed for the provider that will be associated to each link in the email.  In our example below, we are leveraging a SharePoint web service for updating a list item.  Our links in the email will call this Toolset connection passing in the List ID and the appropriate status.  Some of the key information needed in this connection is the <listName>.  This will be the list your updating through this connection.  You will need to change your field names to correspond to your actual field names.  And the <Values> section you will need to include the passthrough parameters for this connection.  One last key component to this connection is the <RedirectTo> node.  This will be the URL that the user will be redirected to after the status is updated.  You will want to add this to provide a more seamless user experience.  If you don’t include this node, the user will see the native SOAP response coming back from the SharePoint web service.  I directed the user to the dashboard in our customer solution.

 

<Data>
    <Name>POApprovalDecision</Name>
    <Default>false</Default>
    <ConnectionType>Web Service</ConnectionType>
    <Request>http://devrapps.corasworks.net/rfdev/hapts/_vti_bin/Lists.asmx</Request>
    <RedirectTo>http://devrapps.corasworks.net/rfdev/hapts/ADefault.aspx</RedirectTo>
    <SOAP>
        <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
            <soap:Body>
                <UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
                    <listName>Purchase Orders</listName>
                    <updates>
                        <Batch OnError="Return">
                            <Method ID="1" Cmd="Update">
                                <Field Name="ID">%ListID%</Field>
                                <Field Name="PO_x0020_Status">%Status%</Field>
                            </Method>
                        </Batch>
                    </updates>
                </UpdateListItems>
            </soap:Body>
        </soap:Envelope>
    </SOAP>
    <SOAPAction>http://schemas.microsoft.com/sharepoint/soap/UpdateListItems</SOAPAction>
    <UseCurrentUserCredentials>2</UseCurrentUserCredentials>
    <UserName>%CWUserID%</UserName>
    <Password>%CWPassword%</Password>
    <OutputType>text/xml</OutputType>
    <Values>
        <ListID />
        <Status />
    </Values>
</Data>

 

2) Build your workflow email using SharePoint Designer.  Of course you will want to include as much detail that the approver will need to make a decision on the Purchase Order approval.  But the main ingredient here are the Approve and Reject links.  You will notice that we are building links to the Toolset provider created in step 1.  We append the ID for the list item and the appropriate status for the link.  These are used by the connection to identify the right purchase order and to update the approval decision.

 

Workflow Email

 

3) The user will receive an email that looks something like this.  The Approve and Reject links execute the provider that updates the status.  And then the user is redirected to the dashboard.

 

Email Notification

 

Imagine all of the one click scenarios you could implement around this technique.  As you implement, please share them with the community so we can all benefit from your creative genius. 

 
Posted by Rodney Fickas on 21-Jul-09

2 comments to Build One Click Approval into Workflow Emails