Get ListItemID from which workflow task was started
In SharePoint 2013 in event receiver (item added) I need to get List item id from which was task started...I have custom list when I add new list item the workflow starts and create new task in task list...After new item is created in task list I need to get ID(List item id of item which start the workflow) in event receiver of Task list... Hmm...In sharepoint 2010 this work

        SPListItem currentTask = properties.ListItem;

        Guid sourceListID = new Guid(currentTask["WorkflowListId"].ToString());
        SPList sourceList = properties.Web.Lists.GetList(sourceListID, true);
        int sourceListItemID = Convert.ToInt32(currentTask["WorkflowItemId"]);
        SPListItem sourceListItem = sourceList.GetItemById(sourceListItemID);

but in sharepoint 2013 not...Thank you
April 25th, 2015 3:08am

hi

try this

SPListItem currentListItem = properties.ListItem;

 if(currentListItem != null)
{
  object associatedWfListId = currentListItem["ows_WorkflowListId"];
  object associatedWfItemId = currentListItem["ows_WorkflowItemId"];

  if (associatedWfItemId != null && associatedWfListId != null)
  {
    SPListItem item = web.Lists.GetList(new Guid(associatedWfListId.ToString()), false).GetItemById(int.Parse(associatedWfItemId.ToString()));
    // THE ABOVE ITEM IS THE ASSOCIATED LIST ITEM
  }
}

https://blogs.blackmarble.co.uk/blogs/jmann/post/2008/03/10/get-the-item-a-workflow-task-is-associated-with.aspx

    
Free Windows Admin Tool Kit Click here and download it now
April 26th, 2015 12:28am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics