04-20-2014 03:05 PM
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.
04-20-2014 03:10 PM
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_StartBasicWorkf...
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.
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.