I have a SharePoint document library and I've created two custom workflow. Then i attached those workflows to a document library. What i'm trying to do is getting workflow status and URL with single REST API.
What I've tried is;
/_api/web/lists/getbytitle('E-Test')/items(37)?$select=DockApprove,DocSignature
DockApprove
and DocSignature
is my custom created workflows, and when i run this on Chrome browser, it returns;
<entry xml:base="http://SPTest/_api/" m:etag=""2""...........">
<id>Web/Lists(guid'5ddb9547-0954-4ad5-bea8-792fb16e1fab')/Items(37)</id>
<category term="SP.Data.ESig" scheme="......."/>
<link rel="edit" href="Web/Lists(guid'5deb9547-0954-4ed5-bef8-792fb16e1fbb')/Items(37)"/>
<title/>
<updated>2023-07-24T11:58:41Z</updated>
<author>
<name/>
</author>
<content type="application/xml">
<m:properties>
<d:DockApprove m:type="Edm.Int32">20</d:DockApprove>
<d:DocSignature m:type="Edm.Int32">5</d:DocSignature>
</m:properties>
</content>
</entry>
DockApprove
returns 20 and DocSignature
returns 5 which they are their status ID.
I need to get full name like "Approved", "Declined" etc.
And i need to get an URL like http://SPTest/_layouts/15/WrkStat.aspx?List=5ddb9547-0954-4ad5-bea8-792fb16e1fab&WorkflowInstanceID=%7b..........%7d
from the REST API.
For URL, I tried to add WorkflowInstanceID
on URL next to Select, but WorkflowInstanceID
always returns null. Since i have multiple workflow, i also tried to expand DockApprove
and DocSignature
, thinking maybe i'll get URL and Status, but i could't get any result.
So is it possible to get custom workflow's status and ID or URL with single or multiple rest API request? Then users can click the URL and easily can go and check the workflow if needed.
Thank you
Update: I found a solution for getting workflow status as a text;
/_api/Web/Lists(guid'......')/Items(37)/FieldValuesAsHtml?$select=DockApprove
and the return is "Approved"
Now I'm trying to get WorkflowInstanceID
or URL for each workflow that i attached to list.
Update: Main idea is creating an url like ..site/_layouts/15/WrkStat.aspx?List=[ListGuid]&WorkflowInstanceID=[WF_InstanceID]
for navigating that workflow details. That's why i need WorkflowInstanceID