0

How Can I get workflow and workflow history for current Item using Sitecore API Item Service?

Get item details using below query

Query to get Item

/item/{id}/database&language&version&includeStandardTemplateFields&includeMetadata&fields

Json Result

{
          "ItemID": "25a40733-babf-4f16-a025-a3ffb0c84c05",
          "ItemName": "itemName",
          "ItemPath": "/sitecore/content/Home",
          "ParentID": "59b7047e-1063-4f2e-a452-4ca466ecb621",
          "TemplateID": "3191fecf-905e-4ca1-a007-05ba9f5b7455",
          "TemplateName": "templatename",
          "CloneSource": null,
          "ItemLanguage": "en",
          "ItemVersion": "1",
          "DisplayName": "testuser",
          "HasChildren": "True",
 }

in the above result don't have the workflow details.

Thanks in advance.

1

You would need to double check but I think you have 2 options here:

  1. Set includeStandardTemplateFields parameter to true (includeStandardTemplateFields=true):
/item/{id}/database&language&version&includeStandardTemplateFields=true&includeMetadata&fields

In this case you should get all the fields of the item.

  1. Set fields parameter to the "," separated fields you want to receive from api (fields=__Workflow,__Workflow%20state,__Display_name):
/item/{id}/database&language&version&includeStandardTemplateFields=true&includeMetadata&fields=__Workflow,__Workflow%20state,__Display_name

In this case you will only get the fields from the parameter.

In both scenarios you will not get the full workflow history anyway. I don't think that's possible with Sitecore API Item Service.

I haven't tested it locally but it should do the trick

3
  • thanks, Marek I will try. Feb 27 '20 at 11:17
  • Marek,Yes, I got only workflow state id, workflow id, current workflow state id.I need workflow history Feb 27 '20 at 12:06
  • As I wrote in my answer: "In both scenarios you will not get the full workflow history anyway. I don't think that's possible with Sitecore API Item Service." Feb 27 '20 at 12:07
0

It does not return Workflow history, but you can check the current workflow state information. Inclde below querystring to get all possible values from the ItemService API:

includeStandardTemplateFields=true (default value is false)

sitecore/api/ssc/item/87D9ADCB-08CE-4396-86C4-8BAE04D833F7/?database=master&includeStandardTemplateFields=true

For more detail, you can check the below Sitecore blog/article

https://doc.sitecore.com/developers/93/sitecore-experience-manager/en/the-restful-api-for-the-itemservice.html

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.