Handling Lookup Columns in a SharePoint Designer Workflow

    • By far the most common mistake is to forget to specify the proper columns to tell SharePoint how to join the listsclip_image010
    • Looking up data on an empty column. If this happens make the lookup column required
    • SharePoint Designer workflows are not portable between servers, lists, libraries, or farms. If you need to develop code in a dedicated development environment consider writing Visual Studio workflows.
  • Problem

    You don’t understand how to lookup data between lists in a SharePoint Designer workflow or you’re not getting data when you lookup information between lists; usually you lookup data when one lists contains a “lookup” column that links to a list item in another list.

    Demonstration

    In this example we are going to create two lists, the first, a master list will provide the information we are going to query on a workflow. After we create the two lists we will walk through a simple non-real-world example of how to query information between the lists in a SharePoint Designer workflow.

    Following the steps below, create two lists: one the master, one the detail. Have the second list item reference the parent list using a lookup column. Add a column that contains information that you would like to retrieve from the parent list such as the column shown below.
    clip_image001

    Populate the master list with a few rows of dataclip_image002

    Create the detail list that contains a “Lookup” column to the master tableclip_image003

    Open the site in SharePoint Designer and create a new workflowclip_image004

    Associate the lookup with the detail list then click nextclip_image005

    Under workflow actions let’s set a workflow variableclip_image006

    Create a variable to store the result of our lookupclip_image007

    Select the function iconclip_image008

    Now change the source list, where we will be pulling our information from, to the master table. Also specify the name of the field that contains the information we want to pullclip_image009

    Next, tell SharePoint how the master and detail lists are linked. This is where mistakes are made! You want to link to the column of the master list that you used to populate the detail list’s lookup columnclip_image010

    Accept the warning messageclip_image011

    Add an action that logs the message to a list (If your SharePoint server is email enabled send the workflow variable in the body of an email message)clip_image012

    The final result of my workflow looks like this

    clip_image013

    Finish the workflow and note how the workflow tree appears under the site navigator in SharePoint Designerclip_image014

    Now test the workflow by adding an item to the detail listclip_image015

    Upon save pull down on the item’s edit menu to view the workflows that are associated with this itemclip_image016

    You will see your workflow in the workflow settings screen and, if everything worked as expected you should see the workflow in the completed listclip_image017

    Click on the hyperlink for the completed workflow to see the history, as you can see we looked up http://www.sharepointassist.com/ from the master list’s “Look Me Up Please!” columnclip_image018

    Common Mistakes

VN:F [1.9.1_1087]
Rating: 4.0/10 (4 votes cast)
VN:F [1.9.1_1087]
Rating: -3 (from 5 votes)
Handling Lookup Columns in a SharePoint Designer Workflow, 4.0 out of 10 based on 4 ratings

Popularity: 43% [?]

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
Share this Post:
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

8 Responses to “Handling Lookup Columns in a SharePoint Designer Workflow”

  • Brendan says:

    Hi, thank you for an excellent article.

    I wonder if you might be able to point me in the right direction with a little problem that is driving me mad.

    In your example screenshots (and others I have seen) in your workflow diaglog boxes, next to the “value” feilds you have two buttons:

    [...] and [Fx]

    In my SharePoint designer (SP2) I only have the Fx button.

    I am guessing the [...] button would allow me to look up fields which is what I need to do.

    Any idea why its missing?

    Really appreciate your help.

    Regards,
    Brendan

    VA:F [1.9.1_1087]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
    • ujludwig says:

      You’re there! Select the [Fx] button and choose a source other than “Current Item”.

      VN:F [1.9.1_1087]
      Rating: 0.0/5 (0 votes cast)
      VN:F [1.9.1_1087]
      Rating: 0 (from 0 votes)
  • Andrew says:

    I used to handle lookup columns in workflows in this way, but I have since figured out that it’s better if you reference the lookup ‘ID’ instead. To do this in your example you must simply change the “Find the List Item” section of your workflow lookup to the following:

    Field = PO Master:ID
    Value = PO Line Detail:PO Number

    This ensures that you are pulling the correct list item because ID is unique and never changes… It could come in handy if you have multiple items in your lookup list with the same title, OR if the title of an item in the lookup list changes mid workflow.

    VA:F [1.9.1_1087]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.1_1087]
    Rating: +1 (from 1 vote)
  • Simon says:

    Thank you! I have just spent the past two days trying to figure out how to do a double lookup on the same list and failed miserably. Now that I have read your explanation my understanding was complete – and I solved my problem in minutes.

    VA:F [1.9.1_1087]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
  • Rob says:

    Does anyone have any information regarding the same problem, but with Visual Studio workflows? Maybe best practices for configuration tables, etc.?

    VA:F [1.9.1_1087]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
    • ujludwig says:

      Rob,

      If you are asking about how to handle SharePoint lookup columns that you want to access from Visual Studio Workflows the same principle will apply. For example, when you access the master list, you can pull the lookup value which will give you the ID of the subordinate list in the “;#39″ format where 39 would be the ID. You can then use that ID value to retrieve the subordinate list using the standard list selection methods.

      VN:F [1.9.1_1087]
      Rating: 0.0/5 (0 votes cast)
      VN:F [1.9.1_1087]
      Rating: 0 (from 0 votes)
  • Eric says:

    This is a bit of an addition to Andrew’s comment. In your lists it is good to use lookups because lookup columns will help you to have uniqueness when you lookup values from another list. Then in your SPD workflow it is also good to save the lookup to a “List Item ID’ variable type. This will save the ID of the lookup, even if your lookup displays the title. This makes it so that your workflow will not break if you change the display column for that lookup and ensures uniqueness.

    Also, this works great if you need to lookup a value from a list where that column is also a lookup to another list. For example, if you have three lists, A, B, and C, where your workflow on list A needs to lookup a column from list B, but that column in list B is a lookup to list C. In this scenario you want to save the lookup to the column in List B as a “List Item ID” variable, and then in another step Lookup whatever column you want from list C where the ID = your List Item ID variable. Again this ensures uniqueness and a change to either lookup column will not break your workflow.

    VA:F [1.9.1_1087]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
  • kalpana says:

    Hi,
    Thank you for the informative post. Can you please show how to extract the value if multi-select is enabled in the lookup column. Once you get the value how can we iterate through the comma delimited string.
    Thanks,
    Kal

    VA:F [1.9.1_1087]
    Rating: 5.0/5 (1 vote cast)
    VA:F [1.9.1_1087]
    Rating: 0 (from 0 votes)
  • Leave a Reply:

    Name (required):
    Mail (will not be published) (required):
    Website:
    Comment (required):
    XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>