English
form.submit.before
About 230 wordsLess than 1 minute
2025-12-15
- Validate data and intercept the submit action
This hook is triggered before object form data is submitted. It allows extra business actions before submission, including but not limited to processing submitted data.
Parameters
| Parameter | Description | Type |
|---|---|---|
| Common parameters | See details | -- |
| objApiName | Main object apiName | String |
| recordType | Main object record type | String |
Return Value
| Parameter | Description | Type | Default |
|---|---|---|---|
| parseParam | Developers can implement this function to process submitted data (example) | Function | -- |
Basic Example
Process submitted data
export default class Plugin {
apply() {
return [{
event: 'form.submit.before',
functional: this.formSubmitBefore.bind(this)
}]
}
// If this is a middleware plugin in a vcrm project, swap the interaction parameter positions
// formSubmitBefore(plugin, context)
formSubmitBefore(context, plugin) {
return Promise.resolve({
parseParam: function(postData){
// Modify main object data
postData.object_data.name = 'test';
// Modify child object data
postData.details.object_K2z2d__c.forEach(item => {
item.xxx = 'test'
})
return postData;
}
})
}
}Validate data and intercept submission
export default class Plugin {
apply() {
return [{
event: 'form.submit.before',
functional: this.formSubmitBefore.bind(this)
}]
}
// If this is a middleware plugin in a vcrm project, swap the interaction parameter positions
// formSubmitBefore(plugin, context)
formSubmitBefore(context, plugin) {
return new Promise((resolve, reject) => {
const masterData = context.dataGetter.getMasterData();
if(masterData.name == 'Beijing') {
// This confirm dialog is only for demonstration. Replace it with your own confirm implementation in real development.
confirm('Are you sure you want to submit the data?', {
onConfirm() {
resolve();
},
onCancel() {
reject()
}
})
}
})
}
}