English
triggerCalAndUIEvent
About 917 wordsAbout 3 min
2025-09-22
Asynchronously triggers calculation and UI events, and by default updates the result into the data layer within the plugin lifecycle.
Parameters
Description of param properties
| Property | Description | Type | Default |
|---|---|---|---|
| objApiName | Required, apiName of the object currently initiating the calculation | String | — |
| modifiedDataIndexs | Required for detail-field change events, list of dataIndex values of modified detail records | Array | — |
| changeFields | Required for field change events, indicates that this calculation was triggered because the corresponding fields were modified | Array | — |
| triggerUiField | Optional, dependency for field-change UI events; the field that triggers the UI event | String | — |
| uiChangedFields | Optional, dependency for field-change UI events; used together with triggerUiField when one UI action changes multiple field values, for example country/province/city/district fields | Array | — |
| newDataIndexs | Required for detail-add events, list of dataIndex values for newly added detail records. Pass this if the calculation is triggered because detail data was added | Array | — |
| delDatas | Required for detail-delete events, complete data list of deleted detail records | Array | — |
| uiEventType | Specifies the UI event type to trigger. Onload event: 5 | String | — |
| uiEventId | Specifies the ID of the UI event to trigger, such as a button event | String | — |
| filterFields | Optional, used to filter the fields that need calculationformat: {SaleOrderProductObj: ['price']}key: apiName of the object containing the filtered fieldsvalue: list of filtered field apiNames | Object | — |
| extraFields | Optional, when the fields triggered by default are not sufficient for the business logic, this can be used to add extra fields that need calculationformat: {SaleOrderProductObj: ['price']}key: apiName of the object containing the appended fieldsvalue: list of appended field apiNames | Object | — |
| disableLoading | Disables the internal loading logic | Boolean | false |
| noMerge | Optional, only triggers calculation without updating the current source data, equivalent to only calling the calculation and UI-event interfaces and returning results | Boolean | false |
| allowCancel | Optional, whether cancel is allowed when calculation or UI event execution fails, and also cancels this data change. true: cancel or retry; false: exit page or retry | Boolean | true |
| disableCal | Optional, disables calculation | Boolean | false |
| disableUIEvent | Optional, disables UI events | Boolean | false |
| beforeCalPost | Optional, synchronously handles the request parameters of this calculation | Function | |
| afterCalPost | Optional, handles the result of this calculation request | Function | |
| beforeUiPost | Optional, handles the request parameters of this UI event | Function | |
| afterUiPost | Optional, handles the result of this UI event request | Function |
Return Value
Asynchronous return result: Promise
| Property | Description | Type |
|---|---|---|
| calRst | Pass-through result returned by the calculation API | Object |
| uiRst | Pass-through result returned by the UI event API | Object |
| updateMaster | Master-object data to update | Object |
| updateDetails | Detail-object data to update | Object |
| addDetails | Detail-object data to add | Object |
| delDetails | Detail-object data to delete | Object |
Example return result
{
"calRst":{},// Pass-through result returned by the calculation API
"uiRst":{},// Pass-through result returned by the UI event API
"updateMaster":{"name":""},// Master-object data to update (incremental data)
"updateDetails":{// Detail-object data to update
"orderproduct": {
"0":{"name":""},// (incremental data)
}
},
"addDetails":{// Detail-object data to add
"orderproduct": [{"name":""}]
},
"delDetails":{// Detail-object data to delete
"orderproduct":[{"name":""},{"name":""}]
}
}Code Examples
- Modify a master-object field, then trigger calculation and UI events
{
event: "form.render.end",
functional: async function (pluginExecResult, options) {// async functions can use await
console.log("custom plugin: form.render.end exec");
let {dataUpdater,bizApi}=options;
dataUpdater.updateMaster({name:'test', 'abc__c':'222'});
// await the completion of the async function
await bizApi.triggerCalAndUIEvent({
objApiName: 'SalesOrderObj',// The object currently initiating the calculation, required
changeFields: ['name', 'abc__c'],// Indicates this calculation is caused by modifying name and abc__c, required
triggerUiField: 'name', // Field that triggers the UI event; if omitted, the UI event is not triggered
})
}
},- Modify a detail-object field, then trigger calculation and UI events
{
event: "form.render.end",
functional: async function (pluginExecResult, options) {// async functions can use await
console.log("custom plugin: form.render.end exec");
let {dataUpdater,bizApi}=options;
dataUpdater.updateDetail('SaleOrderProductObj','1',{name:'test', 'abc__c':'222'});
// await the completion of the async function
await bizApi.triggerCalAndUIEvent({
objApiName: 'SaleOrderProductObj',// The object currently initiating the calculation, required
modifiedDataIndexs: ['1'], // dataIndex of modified detail data
changeFields: ['name', 'abc__c'],// Indicates this calculation is caused by modifying name and abc__c, required
triggerUiField: 'name', // Field that triggers the UI event; if omitted, the UI event is not triggered
})
}
},- Add detail data, then trigger calculation and UI events
{
event: "form.render.end",
functional: async function (pluginExecResult, options) {// async functions can use await
console.log("custom plugin: form.render.end exec");
let {dataUpdater,bizApi}=options;
let newDataIndexs = dataUpdater.add({"record_type": "test", object_describe_api_name: "SaleOrderProductObj"}).map(it=>it.dataIndex);
// await the completion of the async function
await bizApi.triggerCalAndUIEvent({
objApiName: 'SaleOrderProductObj',// The object currently initiating the calculation, required
newDataIndexs, // dataIndex list of newly added detail data
})
}
},- Delete detail data, then trigger calculation and UI events
{
event: "form.render.end",
functional: async function (pluginExecResult, options) {// async functions can use await
console.log("custom plugin: form.render.end exec");
let {dataUpdater,bizApi}=options;
let delDatas = dataUpdater.del("SaleOrderProductObj", ["1"]);
// await the completion of the async function
await bizApi.triggerCalAndUIEvent({
objApiName: 'SaleOrderProductObj',// The object currently initiating the calculation, required
delDatas, // Deleted detail-object data
})
}
},Notes
triggerCalAndUIEventis an asynchronous function. You must wait for it to finish executing; otherwise the execution result will be invalid.- When
noMergeis not explicitly set totrue,triggerCalAndUIEventcannot be called outside the event lifecycle, otherwise the result may be unpredictable.
