sharepoint workflow 2013 find itemId in task

2.1k views Asked by At

I used to Find workflow associated Item id with the SPBuiltInFieldId.WorkflowItemId

but when I use the new sharepoint workflow this column is empty.

What can I do to retrieve Workflow item id from the created task ?

1

There are 1 answers

0
Vetrivelmurugan On

For those who are trying the same using CSOM.

Step 1: First query the list in which the workflow is running with Item ID - 2

Step 2: Read the Field name which is created with your workflow name. 'VetriWorkFlow' is the workflow name and field name.

(FieldUrlValue)mlstItems[0].FieldValues["VetriWorkFlow"];

Step 3: In this field you will be able to see an instance id. Capture the same and pass it to 'WF4InstanceId' column in Workflow Tasks list.

<Where><Eq><FieldRef Name='WF4InstanceId' /><Value Type='Text'>#instanceID</Value></Eq></Where>

Result: You will get the list of tasks that are created for the list item 2.

Hope this helps. If there is any other simple way please share the same.