English
form.change.end
About 248 wordsLess than 1 minute
2025-12-15
This hook is triggered after a main object field changes and all calculations/UI events have finished executing. It allows extra business actions after editing main-object fields and after all calculations/UI events have completed.
Parameters
| Parameter | Description | Type |
|---|---|---|
| Common parameters | See details | -- |
| collectChange | Get the new changed data (example) | Function |
collectChange
| Parameter | Description | Type |
|---|---|---|
| masterUpdate | Updated data of the main object | Object |
| blurField | Field that triggered the current change | String |
| mdAdd | Child-object data added by UI events/calculations | Array |
| mdUpdate | Child-object data updated by UI events/calculations | Object |
| mdDel | Child-object data deleted by UI events/calculations | Array |
Basic Example
Using collectChange
export default class Plugin {
apply() {
return [{
event: 'form.change.end',
functional: this.formChangeEnd.bind(this)
}]
}
// If this is a middleware plugin in a vcrm project, swap the interaction parameter positions
// formChangeEnd(plugin, context)
formChangeEnd(context, plugin) {
return new Promise((resolve, reject) => {
const dataChangeInfo = context.collectChange();
console.log(dataChangeInfo.masterUpdate);
console.log(dataChangeInfo.mdAdd);
// check whether the change was triggered by manually editing the name field
if(dataChangeInfo.blurField == 'name') {
// modify a main-object field value
context.dataUpdater.updateMaster({field_9sIuj__c: 100});
// after modifying a field value, calculations and events usually need to be triggered
context.triggerCalAndUIEvent({changeFields: ['field_9sIuj__c']}).then(rst => {
if(rst.statusCode) { // calculation failed
reject();
} else {
resolve();
}
})
} else if(dataChangeInfo.masterUpdate.field_Z13mQ__c !== void 0) {
// check whether the current change contains changes to a specific field
context.dataUpdater.updateMaster({name: 'test'});
context.triggerCalAndUIEvent({changeFields: ['name']}).then(rst => {
if(rst.statusCode) { // calculation failed
reject();
} else {
resolve();
}
})
}
})
}
}