Using a GUID to look up a SharePoint list item instead of an ID

Learn how you can use the GUID of a SharePoint list item instead of its ID to look up that item when running a SharePoint Designer workflow.

ADVERTISEMENTS

Introduction

I’ve previously written about the basics of defining a workflow lookup in SharePoint Designer. In that article, I also mentioned that you have to ensure that you use either a SharePoint list item ID or GUID to ensure that the item can be found.

In this article, I’ll create a sample workflow – actually 2 workflows – to demonstrate how you can use a GUID to look up a SharePoint list item.

Setting up the SharePoint lists

  1. In SharePoint, create 2 custom SharePoint lists. Name one ParentList and the other ChildList.
  2. Add a Single line of text column named Result to the ParentList SharePoint list.
  3. Add a Single line of text column named ParentListGUID to the ChildList SharePoint list.

Create two SharePoint Designer workflows

If you are unsure how to create a SharePoint Designer workflow, see How to create a custom SharePoint Designer 2007 workflow.

In this sample solution, you’ll create 2 SharePoint workflows: One will be started automatically to run on the ParentList SharePoint list, and the other will be started manually to run on the ChildList SharePoint list.

The workflow on the ParentList will add a new SharePoint list item to the ChildList and store the GUID of the ParentList item in the ChildList item.

The workflow on the ChildList will use the GUID to look up and update the item in the ParentList.

Create the workflow on the ParentList SharePoint list

  1. In SharePoint Designer, create a new SharePoint Designer 2007 workflow.
  2. Attach the workflow to the ParentList SharePoint list.
  3. Select the Automatically start this workflow when a new item is created check box.
  4. Add a Create List Item action to the workflow, select the ChildList as the list to create a new item in, and set the value of the ParentListGUID column in the ChildList SharePoint list to be the same as the GUID column of the Current Item.
  5. Save the workflow.

Create the workflow on the ChildList SharePoint list

  1. In SharePoint Designer, create a new SharePoint Designer 2007 workflow.
  2. Attach the workflow to the ChildList SharePoint list.
  3. Select the Allow this workflow to be manually started from an item check box.
  4. Click Initiation and add a Choice Workflow Initiation Parameter named Result that has two choices Approved and Rejected displayed in a Drop-down menu.
  5. Add an Update List Item action to the workflow, select the ParentList as the list to update an item in, and set the value of the Result column in the ParentList SharePoint list to be the same as the value of the Result workflow initiation parameter (Initiation:Result column of the Workflow Data source).
  6. To find the list item to update, on the Update List Item dialog box, select ParentList:GUID as the field to search on and the ParentListGUID column in the Current Item (ChildList:ParentListGUID) as the value to search for.
  7. Save the workflow.

Test the workflow

Now whenever you add a new item to the ParenList SharePoint list, a new item is automatically created in the ChildList SharePoint list and the ParentListGUID column of the ChildList SharePoint list is populated with the GUID of the item in the ParenList SharePoint list.

You can manually start the workflow on the ChildList SharePoint list and select a Result (Approved or Rejected) when you start the workflow.

The workflow on the ChildList SharePoint list will use the GUID in the ParentListGUID column on the ChildList SharePoint list to find the corresponding item in the ParentList SharePoint list and update its Result column.

Related Articles

ADVERTISEMENTS