Using the Log to History List SharePoint workflow action for debugging
© 2008-2013 DocumentManagementWorkflowInfo.com - Read our Copyright Notice
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.
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:
- Create a new SharePoint Designer workflow and attach it to a SharePoint document library that contains a couple of documents.
- On the Step 1 screen of the Workflow Designer, click Actions, and select More Actions from the drop-down menu that appears.
- 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
- 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.
- 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.
- Repeat steps 2 through 5 to add a Log to History List action for each one of the following fields in the Current Item:
- Server Relative URL
- URL Path
- On the Step 1 screen of the Workflow Designer, click Finish.
- 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.
- 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.
- Click the text Completed to open the Workflow Status page.
- 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 Name||Value Returned|
|Encoded Absolute URL||http://SharePoint_Server_Name/My%20Documents%20Lib/My%20Doc.docx|
|Path||My 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 Name||Value Returned|
|Encoded Absolute URL||http://SharePoint_Server_Name/Lists/My%20List/1_.000|
|Server Relative URL||/Lists/My List/1_.000|
|URL Path||/Lists/My List/1_.000|
where 1 is the ID of the list item.
Copyright: This article may not be used on web sites (whether personal or otherwise), copied, disseminated, altered, printed, published, broadcasted, or reproduced in any way without an expressed written consent of the owner of DocumentManagementWorkflowInfo.com. The techniques demonstrated in this article may be used within any SharePoint project. This article is provided without any warranties. Copyright for this article is non-transferrable and remains with the owner of DocumentManagementWorkflowInfo.com.