As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
When you start a workflow via REST (Context.StartWorkflow operation), how can you get the workflowInstanceId context variable populated by the operation? The REST call returns the JSON document, but not this context variable.
Context.StartWorkflow
workflowInstanceId
One can either:
Here is my REST_StartBasicWorkflow chain:
Fetch > Context Document(s) Workflow Context > Start Workflow id: BasicWorkflowTest Execution Context > Restore input blob from a script script: return new org.nuxeo.ecm.core.api.impl.blob.StringBlob( "{\"workflowInstanceId\":\"" + Context["workflowInstanceId"] + "\"}" );
Then, calling the chain can be done like this:
http://{server}:{port}/nuxeo/api/v1/id/7474306b-dcc9-4023-a616-80a159ddf81c/@op/REST_StartBasicWorkflow
The result will be:
{ workflowInstanceId: "e947194d-8a1e-4d76-9da4-7807e2637d46" }
The external app would then store this Id, and can re-use it later. For example, to cancel the workflow:
POST http://{server}:{port}/nuxeo/site/api/v1/automation/Context.CancelWorkflow Body: {"params":{"id": "e947194d-8a1e-4d76-9da4-7807e2637d46"}, "context":{}}
NOTE: Now, the document is not returned, but you can fill the StringBlob with any information form the document you need.