Share and Enjoy !

I was recently working on a project where the customer wanted to use the default SharePoint Approval workflow, but they wanted to include some additional information on the Task Approval form so that the “approver” did not need to navigate back to the SharePoint Document library to get the key information required to approve or reject the request. In this particular scenario, the customer wanted to add the Vendor name and the Invoice amount fields. Having customized Approval forms in the past that were related to SharePoint custom lists, I thought this would be relatively straightforward; it turns out that the process is a bit different between lists and document libraries.

To get started, you will need to open SharePoint Designer and navigate to the appropriate SharePoint site. Next, navigate to the Workflows folder and make a copy of the Approval – SharePoint 2010 as demonstrated below. SharePoint 2010 workflows run in both 2010 and 2013 environments.

Right-click the Approval-SharePoint 2010 workflow and select Copy and Modify. Add the name of the workflow (in my case, “Demonstrate Custom Columns on Approval Form”) and select the Content Type. In this scenario, I am associating this approval workflow with a custom Document Set content type called Custom Document Set.

After providing the workflow name and associated content type, click OK to save the new workflow. I also recommend publishing the workflow at this point so that it will go ahead and generate the default InfoPath Approval Form. Note that the default name of the InfoPath form will be ugly. I won’t go into detail in this blog, but there are ways to manipulate this name in the associated .xoml and xoml.wfconfig.xml workflow files prior to publishing the workflow so you can have a nicer name.

Having created a copy of the “out of box” Approval workflow and published it, we can now edit the workflow. Click the name of the Approval task as highlighted below.

You will see a Task Form Fields section in the top-right of this screen. Here we want to add two new Task Form Fields by clicking on the New button.

Add a field called Vendor as a single line of text.

Next, add Invoice Amount as Currency.

After completing these steps, publish the Workflow again to persist these changes. This has basically added two new fields to the task content type associated with this Approval workflow.

Next, we need to open up the task approval form and add the new fields. Click on the form name to launch InfoPath where we can edit the form.

After the form opens in InfoPath, right-click the Status column and select Insert Row above.

After the new row has been added, enter the Vendor text in the label column.

Next, in the data area of the form, add the Calculated Value object from the Controls list as demonstrated in the 2 screen shots below.

To see the Calculated Value option, select the small arrow in the bottom of the controls list.

After clicking this arrow, you will see the Calculated Value option as demonstrated below.

Next, select the Vendor field from the Fields list as demonstrated below. This screen shot displays the culmination of having clicked the “fx” button and selected the “Insert Field or Group”. Select the Vendor option.

Repeat these same steps to add the Invoice Amount column to the form. For the Invoice Amount column, you can choose to display the value formatted as currency as show below.

Publish the updates to the form by clicking the blue “up arrow” in the top of the InfoPath form.

Allow InfoPath to save a local copy as part of the Publish process as shown below.

You should receive a message indicating the Publish was successful.

At this point, Publish the workflow again so that the updates to the InfoPath form are saved with the Workflow.

Now that we have added fields to the task content type and updated our InfoPath form to display those fields from the task content type, we need to populate those task fields within the workflow.

Edit the Workflow and click the Approval task name as demonstrated below.

Next, select the “Change the behavior of a single task” option.

In the “Before a Task is Assigned” section, add a “Set Task Field” action. Select the Vendor field from the list of Task fields and select the Current Item: Vendor field from the fields displayed in the Current Item. Basically this is populating the Task field called Vendor with the Vendor value from the Current Item before creating the Task. Repeat the same steps for the Invoice Amount field.

Publish the workflow again to persist the changes to the workflow.

Now when you run the workflow and an Approver opens up the Task Approval form, they will see the new Vendor and Invoice Amount fields populated which will help them decide to Approve or not.

One limitation of this solution to point out is that the values on the Task Approval Form are captured at the time the workflow runs and are not dynamic. So, if these values are changed in the document library, the changes will not be shown in this form. The rule of thumb should be that any changes to the underlying data in the document library should prompt any running Approval Workflows to be cancelled and a new one started. This would make sense since approvers in a multi-step approval process may have already approved based on the original values.

Share and Enjoy !

Related Content: