English
md.batchAdd.after
About 232 wordsLess than 1 minute
2025-12-15
This hook is triggered after selecting data during batch creation of child-object data and before UI events/calculation logic are executed. It allows extra business actions, 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 |
| lookupField | Field metadata of the lookup field used when creating the child object | Object |
| newDataIndexs | Row IDs of the newly added child-object data | Array |
| lookupDatas | Related object data selected to create child-object data | Array |
Basic Example
Modify the newly created child-object data
export default class Plugin {
apply() {
return [{
event: 'md.batchAdd.after',
functional: this.mdBatchAddAfter.bind(this)
}]
}
// If this is a middleware plugin in a vcrm project, swap the interaction parameter positions
// mdBatchAddAfter(plugin, context)
mdBatchAddAfter(context, plugin) {
const { dataGetter, dataUpdater, newDataIndexs, objApiName } = context;
const detailDatas = dataGetter.getDetail(objApiName);
newDataIndexs.forEach(rowId => {
const newData = detailDatas.find(item => item.rowId === rowId);
if(newData){
dataUpdater.updateDetail(newData.object_describe_api_name, rowId, { name: 'hello fxiaoke' })
}
});
}
}Notes
1. Child-object data obtained through context APIs in this hook includes the newly created data
When this hook is called, object data has already been created and is waiting for subsequent UI events/calculations, so the API can find the new data in the object data.
