Using the Log to History List SharePoint workflow action for debugging

Learn how you can use the Log to History List SharePoint Designer workflow action to not only log workflow status messages to the history list, but also debug SharePoint workflows.

Introduction

You can use the Log to History List SharePoint Designer workflow action to write messages to the workflow history list during the lifetime of a workflow. These messages can serve as a way to report the status of the workflow back to the user.

You can also use the Log to History List SharePoint Designer workflow action to debug a SharePoint Designer workflow or to find out whether a workflow is returning the values you expect it to while it’s running.

To illustrate how you can use the Log to History List SharePoint Designer workflow action to debug a SharePoint Designer workflow, consider the following situation…

The Current Item source in a SharePoint Designer workflow has several URL fields such as Encoded Absolute URL, Path, Server Relative URL, and URL Path that you can use. How would you know which URL field to use if you don’t know what kind of values they return?

An easy way to find out what kind of values the URL fields on the Current Item return, is to create a workflow that contains Log to History List SharePoint Designer workflow actions for each URL field for which you want to know its return value.

Using the Log to History List workflow action to display workflow values

To create a SharePoint Designer workflow for testing purposes:

  1. Create a new SharePoint Designer workflow and attach it to a SharePoint document library that contains a couple of documents.
  2. On the Step 1 screen of the Workflow Designer, click Actions, and select More Actions from the drop-down menu that appears.
  3. On the Workflow Actions dialog box, select Core Actions from the category drop-down list box, select Log to History List from the actions list box, and click Add. The following workflow action text appears on the Workflow Designer:

    Log this message to the workflow history list

  4. On the Step 1 screen of the Workflow Designer, click this message, and then click the formula button (second button) behind the text field that appears.
  5. On the Define Workflow Lookup dialog box, select Current Item from the source drop-down list box, select Encoded Absolute URL from the field drop-down list box, and click OK.
  6. Repeat steps 2 through 5 to add a Log to History List action for each one of the following fields in the Current Item:
    • Path
    • Server Relative URL
    • URL Path
  7. On the Step 1 screen of the Workflow Designer, click Finish.
  8. Once you’re done creating the sample workflow, go to the SharePoint document library to which you attached the workflow and manually start the workflow on a document in the library.
  9. Press F5 to refresh the contents of the SharePoint page. Once the workflow has run, a column with the name of the workflow and the text Completed will appear in the SharePoint document library.
  10. Click the text Completed to open the Workflow Status page.
  11. You’ll see the values for the URL fields recorded by the Log to History List workflow action listed under the Workflow History on the Workflow Status page.

Displaying the values of URL fields using the Log to History List action

The values for the fields from the Current Item from a SharePoint document library are listed in the table below for a SharePoint document library named My Documents Lib and a document named My Doc.docx.

URL Field NameValue Returned
Encoded Absolute URLhttp://SharePoint_Server_Name/My%20Documents%20Lib/My%20Doc.docx
PathMy Documents Lib
Server Relative URL/My Documents Lib/My Doc.docx
URL Path/My Documents Lib/My Doc.docx

The same values for a SharePoint list item named My Item in a list named My List are listed in the table below.

URL Field NameValue Returned
Encoded Absolute URLhttp://SharePoint_Server_Name/Lists/My%20List/1_.000
PathLists/My List
Server Relative URL/Lists/My List/1_.000
URL Path/Lists/My List/1_.000

where 1 is the ID of the list item.

Related Articles