English
md.add.after
About 251 wordsLess than 1 minute
2025-12-15
This hook is triggered after child-object data is added and before UI events/calculation logic are executed. It allows extra business actions after adding child-object data, including but not limited to modifying main and child object field values.
- Modify field values of the main object and child objects
Parameters
| Parameter | Description | Type |
|---|---|---|
| Common parameters | See details | -- |
| objApiName | Child object apiName | String |
| recordType | Child object record type | String |
| newData | Newly added child-object data | Object |
| newDataIndexs | Row IDs of the newly added child-object data | Array |
Basic Example
Modify other field values
export default class Plugin {
apply() {
return [{
event: 'md.add.after',
functional: this.mdAddAfter.bind(this)
}]
}
// If this is a middleware plugin in a vcrm project, swap the interaction parameter positions
// mdAddAfter(plugin, context)
mdAddAfter(context, plugin) {
// Update main object data
context.dataUpdater.updateMaster({name: 'hello fxiaoke'});
// Update other child-object data
context.dataGetter.getDetail(context.objApiName).forEach(item => {
context.dataUpdater.updateDetail(item.object_describe_api_name, item.rowId, { name: 'hello fxiaoke' })
})
}
}Notes
1. Field values changed in this hook will also participate in subsequent calculations/UI events
After data is modified in this hook, subsequent calculations and UI events will be processed based on the updated values.
2. Unlike md.render.before, child-object data obtained through context APIs in this hook includes the newly added data
When this hook is called, the object data has already been created and is waiting for subsequent UI events/calculations to run, so the API can find the newly added data in the object data.
