Skip to main content

Invoking workflow for an entry using the event name and event data

Log in to add to favourites

Workflow 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

Name Type Format Description
entry object Entry The entry object.
event string The event type, as described at Workflow
data? object The optional event data.

Returns

A Promise that will resolve with an Entry object.

Example

JavaScript
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

JavaScript
   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);      
});

Still need help?

If you still need help after reading this article, don't hesitate to reach out to the Contensis community on Slack or raise a support ticket to get help from our team.
New support request