Invoking workflow for an entry using the event name and event data
Log in to add to favouritesWorkflow events can be invoked for a specific entry by passing the event name and the event data.
invokeWorkflow(entry: Entry, event: string, data?: any): Promise<Entry>
Parameters
Returns
A Promise that will resolve with an Entry object.
Example
client.entries.invokeWorkflow(existingEntry, 'draft.publish')
.then(result => {
console.log('API call result: ', result);
})
.catch(error => {
console.log('API call fetch error: ', error);
});
Workflow events can be invoked for a specific entry by passing a workflow trigger object. This method allows more flexibility than invokeWorkflow as you can omit the language and the version number if not required. You should use this method when you need to unpublish an entry, like in the example below.
invokeWorkflowByTrigger(entry: Entry, workflowTrigger: WorkflowTrigger): Promise<Entry>
Parameters
Name | Type | Format | Description |
---|---|---|---|
entry | object | Entry | The entry object. |
workflowTrigger | object | WorkflowTrigger | The workflow trigger object type. |
Returns
A Promise that will resolve with an Entry object.
Example
client.entries.invokeWorkflowByTrigger(existingEntry, {
event: 'sysUnpublish',
language: 'en-GB'
})
.then(result => {
console.log('API call result: ', result);
})
.catch(error => {
console.log('API call fetch error: ', error);
});