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:
name | type | description |
---|---|---|
item | Itemobject | Item data |
itemId | String | Item id |
itemType | String | Item type |
workspace | String | Workspace id |
user | User | User information |
userWorkspaceRoles | String[] | User workspace role ids |
userGroups | String[] | User group ids |
Api reference
getItem
Get item data
API PARAMETERS:
name | type | required | description |
---|---|---|---|
itemId | String | true | Item 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:
name | type | required | description |
---|---|---|---|
itemId | String | true | Child 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:
name | type | required | description |
---|---|---|---|
itemId | String | true | Parent 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:
name | type | required | description |
---|---|---|---|
itemId | String | true | Parent 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:
name | type | required | description |
---|---|---|---|
itemId | String | true | Parent 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:
name | type | required | description |
---|---|---|---|
itemId | String | true | Item id |
isDestinationItem | Boolean | false | Association 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:
name | type | required | description |
---|---|---|---|
itemId | String | true | Item 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:
name | type | required | description |
---|---|---|---|
method | String | true | GET/POST/PUT/PATCH |
url | String | true | The requested url |
data | Object | false | The requested data |
EXAMPLE:
const result = await apis.requestCoreApi('POST', '/parse/api/search/structure', data);
console.log(result)