Skip to main content

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:

nametypedescription
bodyValObjectParameter collection
bodyVal.workspaceStringWorkspace id
bodyVal.itemTypeIdStringItem type id
bodyVal.screenStringScreen type: view,create,edit
bodyVal.parentIdStringParent item id
bodyVal.inwardItemIdStringInward 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:

nametyperequireddescription
itemIdStringtrueItem 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:

nametyperequireddescription
itemIdStringtrueItem id

RETURN:

ItemTypeObject - Item type data

EXAMPLE:

const itemTypeData = await apis.getItemType(bodyVal.itemId);
if(itemTypeData.name === 'item name'){
return {
value1: 1
}
}