English
md.del.before
About 230 wordsLess than 1 minute
2025-12-15
This hook is triggered before deleting child-object data, including batch deletion. It allows extra business actions before deletion, including but not limited to intercepting deletion.
- Intercept deletion of child-object data
Parameters
| Parameter | Description | Type |
|---|---|---|
| Common parameters | See details | -- |
| objApiName | Child object apiName | String |
| recordType | Child object record type | String |
| delDatas | Child-object data being deleted | Array |
Return Value
None
Basic Example
Require users to fill in a deletion reason before deleting child-object data
Requirement description: when employees delete existing child-object data, they must first fill in a deletion reason, then perform the deletion, and the system records the deleted items and reasons.
import resonInputDialog from './resonInput';
const ResonInputDialog = Vue.extend(resonInputDialog);
export default class Plugin {
apply() {
return [{
event: 'md.del.before',
functional: this.mdDelBefore.bind(this)
}]
}
mdDelBefore(context, plugin) {
return new Promise(resolve => {
const { delDatas = [] } = context;
const delIds = delDatas.filter(item => item._id);
if(delIds.length){
const div = document.createElement('div');
document.body.appendChild(div);
const dialog = this.instance = new ResonInputDialog({
el: div,
propsData: {
mainId: data._id || '',
delIds: delIds,
success: () => {
destroy();
resolve();
},
fail: () => {
destroy();
reject();
}
}
});
return;
}
})
}
destroy(){
if(this.instance){
this.instance.$destroy();
this.instance = null;
}
}
}Notes
1. Child-object data obtained through context APIs in this hook does not include the deleted data
When object data is retrieved through context APIs in this hook, the data has already been deleted, so the APIs can no longer find it.
