Field Default Value
Introduction
What is field default value
Field default value refers to the default value given to the field when the form is created
Field default value script
The field default value script is a script executed before the form is created, returning the default value of the form field. The field default value script can be configured in the interface configuration:
Field default value script take effect
After configuring the field behavior, it can take effect when the form is created:
Script parameters
The following parameters can be used directly in the script:
name | type | description |
---|---|---|
bodyVal | Object | Parameter collection |
bodyVal.workspace | String | Workspace id |
bodyVal.itemTypeId | String | Item type id |
bodyVal.screen | String | Screen type: view,create,edit |
bodyVal.parentId | String | Parent item id |
bodyVal.inwardItemId | String | Inward Item Id(Item Link) |
According to the provided parameters, cooperate with the function capabilities provided by the system, and finally return the field default value
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(bodyVal.parentId);
if(data.name === 'item name'){
return {
value1: 1
}
}
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(bodyVal.itemId);
if(itemTypeData.name === 'item name'){
return {
value1: 1
}
}