English
md.excelimport.before
About 186 wordsLess than 1 minute
2025-12-15
This hook is triggered before importing local data from Excel. It can be used to perform additional processing on imported data.
- Intercept import operations
- Customize imported data
- Customize imported data columns
- Customize export error messages
- Customize buttons on the import prompt page
Parameters
| Parameter | Description | Type |
|---|---|---|
| Common parameters | See details | -- |
| objApiName | Child object apiName | String |
| recordType | Child object record type | String |
Return Value
| Parameter | Description | Type | Default |
|---|---|---|---|
| importConfig | Custom import operations | Object | -- |
importConfig
| Parameter | Description | Type | Default |
|---|---|---|---|
| afterFormatDatas | Format data, customize error prompts, customize buttons, etc. | Object | -- |
| filtersMappingFields | Filter import fields | Function | -- |
| forceImportFields | Force support for importing read-only or special fields | Array | -- |
| filterExcelDatas | Filter Excel data | Function | -- |
| validateMappingFields | Custom field-mapping validation information | Function | -- |
Basic Example
Custom error messages / custom buttons
export default class Plugin {
apply() {
return [{
event: 'md.excelimport.before',
functional: this.mdExcelImportBefore.bind(this)
}]
}
mdExcelImportBefore(context, plugin) {
return Promise.resolve({
importConfig: {
afterFormatDatas(opts) {
const {formatDatas} = context;
let messages = {};
formatDatas.forEach(data => {
if(!data.name) {
messages[data.rowId] = {
type: 'error',
content: 'Name cannot be empty'
}
}
})
return Promise.resolve({
buttons: [{
label: 'Download Invalid Data',
callBack() {}
}],
messages,
stopImport:true,
onlyShowError: true
})
}
}
})
}
}