5

I have a Approve/Reject workflow attached to a library. Is there a way to get the Workflow Instance Id from the list item using REST API?

I know it is possible with 'SPListItem.Workflows' in server-side API but in my case I need a REST equivalent.

Idea is to query Workflow History list with "List" and "WorkflowInstance" columns.

1

In a SharePoint list if you attach any workflow it will a column with your workflow name. It is a Hyperlink column which can be used to get that full url to query workflow history list.

See below screenshot how it returns results from REST call.

enter image description here

I have used below query to get that

<<site url>>/_api/web/Lists/getByTitle('<<list title>>')/Items(<<item id>>)

It returns all columns but from results you will get that workflow column

0

Question 1: Workflow Instance Id from the list item

Make a GET request to the following URL, you will get two fields name WorkflowInstanceID and WorkflowVersion along with other columns.

/_api/web/lists/GetByTitle('Your Library Name')/Fields

So you can get Workflow Instance Ids for all items in your library by following URL

/_api/web/lists/GetByTitle('Your Library Name')/Items?$select=WorkflowInstanceID

For a particular Item, let say ID of the Item is 11

/_api/web/lists/GetByTitle('Your Library Name')/Items(11)?$select=WorkflowInstanceID

Question 2: Idea is to query Workflow History

Workflow History is just a list like any other list. So you can apply same idea over here also.

/_api/web/lists/GetByTitle('Workflow History')/Items
  • 2
    Hi Atish, thank you for your suggestion. In fact I tried that but due to some reason WorkflowInstanceId is coming as null when I retrieved list items. – Arun Nov 6 '15 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.