LookupSPList, LookupSPListItem, LookupSPListItemId Activities in Visual Studio 2013 For SharePoint 2013

This article explains how to use the LookupSPList, LookupSPListItem and LookupSPListItemId activities in Visual Studio 2013 for SharePoint 2013 Workflows.

Implementation Procedure

  1. Open the SharePoint site and create a custom list called “WFSPListObjects”.
  2. Create New SharePoint 2013 - Empty Project and provide the name as you want.

    Empty Project

  3. Click Ok. In the next window provide the site collection name you want to deploy the project to and choose Sandboxed Solution.

    Sandboxed Solution

  4. Click Finish and wait for some time to create the project.
  5. Add new item as Workflow and provide the name as “WFSPList”.

    WFSPList

  6. In the next window provide the name of the workflow and choose the List Workflow option and click Next.

    Workflow

  7. Select the List, History List and Task List as shown below.

    History List

  8. Click Next. Leave it as the default selection (A user manually stats workflow option).

    start workflow

  9. Click Finish. Then you will see the designer screen as below.

    designer screen

  10. Drag and drop the WriteToHistory Activity to the sequence from the Toolbox as shown below.

    WriteToHistory

  11. Select the WriteToHistory activity and press F4 to open the properties window. In the properties window provide the display name as Log WF Started and click on the button (…) and provide the message as “WF Started” in the Expression Editor window.

    WF Started

  12. Repeat Step 11 for another WriteToHistory activity. Display Name – Log WF Completed. Message – “WF Completed”.
  13. Select Sequence and click on Variables

    Sequence

  14. In the Variable window click on Create Variable and provide the variable name as listProperties and set the variable type as Dynamic Value.

    listProperties
    listProperties2
    listProperties3


  15. Again follow Step 13 to remove the Variable window.
  16. Drag and drop the LookupSPList activity (Under SP – List category) between the WriteToHistory activity and set the properties as below.

    LookupSPList
  17. Click Get Properties on LookupSPList activity and see that the listProperties variable is set to the source.

    listProperties 17

  18. Click "Define…" in the GetDynamicValueProperties and select the entity type as below.

    GetDynamicValueProperties

  19. Double-click on Create Property from the Properties window and Select Title, Created as shown below.

    Create Property

  20. Click on Populate Variables in the properties window and see the Title and Created Variable in the Assign To Column.

    Assign To Column

  21. Drag and drop the WriteToHistory activity and provide the input message as string.Format("List Title : {0}, List Created Date : {1}", Title, Created.ToString())
  22. Create a new variable called “listItemProperties” and set the variable type as “Dynamic Value”.
  23. Drag and drop the LookupSPListItem activity to the designer (before Log WF Completed – WriteToHistory activity) and set the properties as below.

    listItemProperties

  24. Click Get Properties on LookupSPListItem and click on "Define…" in the GetDynamicValueProperties activity.
  25. Set the value in the properties window as shown below.

    •  Entity Type: List Item of WFSPListObjects
    •  Path: ID, Title
    •  Click on Populate Variables – Automatically ID and Title1 variable will be created and assigned.

      WFSPListObjects

       
  26. Drag and drop the WriteToHistory activity and provide the input message as string.Format("List Item ID : {0}, List Item Title : {1}", ID.ToString(), Title1)
  27. Create a new variable called “listItemID” and set the variable type as “Int32”.
  28. Drag and drop the LookupSPListItemId activity and set the properties as shown below.

    LookupSPListItemId activity

  29. Drag – WriteToHistory activity. Input Message as : string.Format("List Item Id : {0}", listItemID.ToString())
  30. Build and deploy the workflow.
  31. Go to the list URL in the SharePoint site and add a new item.
  32. Click on (…) and select Workflows as below.

     Workflows

  33. Click on the link as below.

     link

  34. Again follow Step 32 and click on started in the next screen.
  35. Refresh the page for a few seconds and see the output in the workflow history.

    output