Workflow

Workflow

Source:
Workflow is a tool that allows you to streamline the process of content creation and publishing, and lets you manage the content lifecycle of your project smoothly. Read more about Workflows and Publish Rules.

Methods

(static) update() → {Promise.<Workflow.Workflow>}

Source:
The Update Workflow request allows you to add a workflow stage or update the details of the existing stages of a workflow.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).workflow('workflow_uid').fetch()
.then((workflow) => {
 workflow.name = 'My New Workflow'
 workflow.description = 'Workflow description'
 return workflow.update()
})
.then((workflow) => console.log(workflow))
Returns:
Promise for Workflow instance
Type
Promise.<Workflow.Workflow>

(static) disable() → {Promise.<Workflow.Workflow>}

Source:
The Disable Workflow request allows you to disable a workflow.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).workflow('workflow_uid').disable()
.then((workflow) => console.log(workflow))
Returns:
Promise for Workflow instance
Type
Promise.<Workflow.Workflow>

(static) enable() → {Promise.<Workflow.Workflow>}

Source:
The Enable Workflow request allows you to enable a workflow.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).workflow('workflow_uid').enable()
.then((workflow) => console.log(workflow))
Returns:
Promise for Workflow instance
Type
Promise.<Workflow.Workflow>

(static) delete() → {Object}

Source:
The Delete Workflow call is used to delete an existing Workflow permanently from your Stack.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).workflow('workflow_uid').delete()
.then((response) => console.log(response.notice))
Returns:
Response Object.
Type
Object

(static) fetch() → {Promise.<Workflow.Workflow>}

Source:
The fetch workflow retrieves the comprehensive details of a specific Workflow of a stack.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).workflow('workflow_uid').fetch()
.then((workflow) => console.log(workflow))
Returns:
Promise for Workflow instance
Type
Promise.<Workflow.Workflow>

(static) getPublishRules(action, locale, environment) → {Object|ContentstackCollection}

Source:
The Delete Workflow call is used to delete an existing Workflow permanently from your Stack.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).workflow('workflow_uid').contentType('contentType_uid').getPublishRules()
.then((collection) => console.log(collection))
Parameters:
Name Type Description
action string Enter the action that has been set in the Publishing Rule. Example:publish/unpublish
locale string Enter the code of the locale where your Publishing Rule will be applicable.
environment string Enter the UID of the environment where your Publishing Rule will be applicable.
Returns:
  • Returns Object.
    Type
    Object
  • Result collection of content of PublishRules.
    Type
    ContentstackCollection

(static) create() → {Promise.<Workflow.Workflow>}

Source:
The Create a Workflow request allows you to create a Workflow.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

const workflow = {
"workflow_stages": [
     {
       "color": "#2196f3",
       "SYS_ACL": {
         "roles": {
           "uids": []
         },
         "users": {
         "uids": [
           "$all"
         ]
       },
       "others": {}
     },
     "next_available_stages": [
       "$all"
     ],
     "allStages": true,
     "allUsers": true,
     "specificStages": false,
     "specificUsers": false,
     "entry_lock": "$none", //assign any one of the assign any one of the ($none/$others/$all)
     "name": "Review"
   },
   {
     "color": "#74ba76",
     "SYS_ACL": {
       "roles": {
         "uids": []
       },
       "users": {
         "uids": [
           "$all"
         ]
       },
       "others": {}
     },
     "allStages": true,
     "allUsers": true,
     "specificStages": false,
     "specificUsers": false,
     "next_available_stages": [
         "$all"
       ],
       "entry_lock": "$none",
       "name": "Complete"
     }
   ],
   "admin_users": {
     "users": []
   },
     "name": "Workflow Name",
     "enabled": true,
     "content_types": [
       "$all"
     ]
 }
 client.stack().workflow().create({ workflow })
.then((workflow) => console.log(workflow))
Returns:
Promise for Workflow instance
Type
Promise.<Workflow.Workflow>

(static) fetchAll(limit, skip, include_count) → {ContentstackCollection}

Source:
The Get all Workflows request retrieves the details of all the Workflows of a stack.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).workflow().fetchAll()
.then((collection) => console.log(collection))
Parameters:
Name Type Description
limit Int The limit parameter will return a specific number of Workflows in the output.
skip Int The skip parameter will skip a specific number of Workflows in the output.
include_count Boolean To retrieve the count of Workflows.
Returns:
Result collection of content of specified module.
Type
ContentstackCollection

(static) publishRule(ruleUid) → {PublishRules}

Source:
The Publish rule allow you to create, fetch, delete, update the publish rules.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).workflow().publishRule().fetchAll()
.then((collection) => console.log(collection))

client.stack({ api_key: 'api_key'}).workflow().publishRule('rule_uid').fetch()
.then((publishrule) => console.log(publishrule))
Parameters:
Name Type Description
ruleUid Int The UID of the Publish rules you want to get details.
Returns:
Instace of PublishRules.
Type
PublishRules