Skip to main content

Workflow Validation

Introduction

What is workflow validation

Workflow verification refers to the verification that is triggered when the status of the item is transferred.

Workflow validation script

The workflow validation script can be set in the workflow action of the workflow configuration:

Workflow validation script take effect

Modify item status

Trigger workflow validation:

Script parameters

The following parameters can be used directly in the script:

nametypedescription
itemItemobjectItem data
itemIdStringItem id
itemTypeStringItem type
workspaceStringWorkspace id
userUserUser information
userWorkspaceRolesString[]User workspace role ids
userGroupsString[]User group ids

Api reference

getItem

Get item data

API PARAMETERS:

nametyperequireddescription
itemIdStringtrueItem id

RETURN:

ItemJSONObject - Item data

EXAMPLE:

const data = await apis.getItem(itemId);
if(data.name !== 'item name'){
throw new Error('This is an error message')
}

getParentItem

Get parent item data

API PARAMETERS:

nametyperequireddescription
itemIdStringtrueChild item id

RETURN:

ItemJSONObject - Item data

EXAMPLE:

const parentData = await apis.getParentItem(itemId);
if(parentData.name !== 'item name'){
throw new Error('This is an error message')
}

getSubItems

Get the child item list according to the parent item id, if there is no child item, return an empty list

API PARAMETERS:

nametyperequireddescription
itemIdStringtrueParent item id

RETURN:

ItemObject[] - Item data list

EXAMPLE:

const subItems = await apis.getSubItems(itemId);
if(subItems.length<=0){
throw new Error('No sub-items')
}

getAllSubItems

Get the child item list according to the parent item id, if there is no child item, return an empty list, which contains hidden child items

API PARAMETERS:

nametyperequireddescription
itemIdStringtrueParent item id

RETURN:

ItemObject[] - Item data list

EXAMPLE:

const subItems = await apis.getAllSubItems(itemId);
if(subItems.length<=0){
throw new Error('No sub-items')
}

getChildren

Get the list of first-level child items according to the parent item id, and return an empty list if there is no child item

API PARAMETERS:

nametyperequireddescription
itemIdStringtrueParent item id

RETURN:

ItemObject[] - Item data list

EXAMPLE:

const subItems = await apis.getChildren(itemId);
if(subItems.length<=0){
throw new Error('No sub-items')
}

getLinkItems

Get link item list

API PARAMETERS:

nametyperequireddescription
itemIdStringtrueItem id
isDestinationItemBooleanfalseAssociation direction, default false

RETURN:

LinkItemResult - Link item data

type LinkItemResult = Record<string, { name: string; items: ItemJSONObject[] }>

EXAMPLE:

const linkItems = await apis.getLinkItems(itemId);
if(linkItems.length<=0) {
throw new Error('No link item')
}

getItemType

Get item type

API PARAMETERS:

nametyperequireddescription
itemIdStringtrueItem id

RETURN:

ItemTypeObject - Item type data

EXAMPLE:

const itemTypeData = await apis.getItemType(itemId);
if(itemTypeData,key!=='story'){
throw new Error('Not story')
}

requestCoreApi

Provide the ability to directly call the core interface externally, and expose the GET/POST/PUT/PATCH methods

API PARAMETERS:

nametyperequireddescription
methodStringtrueGET/POST/PUT/PATCH
urlStringtrueThe requested url
dataObjectfalseThe requested data

EXAMPLE:

const result = await apis.requestCoreApi('POST', '/parse/api/search/structure', data);
console.log(result)