English
flow.approval.action.before
About 324 wordsAbout 1 min
2026-04-17
flow.approval.action.before
Description: This hook is used to intercept, supplement parameters, and replace logic before an approval action is formally executed.
1. isIntercept
Feature Description
- Intercepts, supplements parameters, and replaces logic before an approval action is formally executed.
- Supports setting whether the reason for changing the approver is required.
- Supports setting the default selected add-sign mode in pre-add-sign scenarios.
Parameters
| Parameter | Description | Type |
|---|---|---|
| action | Current action information | Object |
| context | Context capabilities passed through to the plugin | Object |
Return Value
| Parameter | Description | Type |
|---|---|---|
| isIntercept | Whether to intercept the default action | Boolean |
Parameter Code Example
let action = options && options.action;Code Example
module.exports = function (context, pluginService, pluginParam) {
return {
apply() {
return [
{
event: "flow.approval.action.before",
functional: async function (context, options) {
let action = options && options.action;
let pluginContext = options && options.context;
pluginContext.setChangeApproverExtData({
isRequired: true,
});
pluginContext.setDefaultSequence(true);
// Set whether pre-add-sign comments are required, `true` means required and `false` means not required
pluginContext.setPreAddSignOpinionRequired(true);
return Promise.resolve({
isIntercept: false
});
}
}
];
}
};
};2. Retrieve Operation - Set Default Comment
Feature Description
In retrieve operation scenarios, custom default retrieve comment content can be set through context.setRetrieveOpinionInfo.
context Methods
| Method | Description | Input |
|---|---|---|
| setRetrieveOpinionInfo | Sets retrieve comment information | { defaultOpinion: String } |
Input Details
| Parameter | Description | Type | Required |
|---|---|---|---|
| defaultOpinion | Default retrieve comment content | String | No |
Code Example
module.exports = function (context, pluginService, pluginParam) {
return {
apply() {
return [
{
event: "flow.approval.action.before",
functional: async function (context, options) {
let pluginCtx = options && options.context;
pluginCtx.setRetrieveOpinionInfo({
defaultOpinion: 'Custom retrieve review comment'
});
return Promise.resolve();
}
},
];
}
};
};Notes
setChangeApproverExtDatacan be used to set whether the reason for changing the approver is required.setPreAddSignOpinionRequiredis used to set whether pre-add-sign comments are required.truemeans required andfalsemeans not required.setDefaultSequenceis used to set the default add-sign mode in pre-add-sign scenarios.truemeans parallel andfalsemeans serial.setRetrieveOpinionInfoUsed to set default retrieve comment content in retrieve operation scenarios. It takes effect only when the action is retrieve.
