English
approval.opinions.render.before
About 294 wordsLess than 1 minute
2025-12-16
Description: this event is called before rendering approval opinions
This event is used to perform extra actions before rendering approval opinions, including but not limited to: 1. Retrieving approval opinion data 2. Customizing the approval opinion area
Parameters
| Parameter | Description | Type |
|---|---|---|
| getOpinionsData | Gets approval opinion data (Example) | Function |
| setCustomData | Customizes the approval opinion area (Example) | Function |
Examples
1. getOpinionsData
Description
Gets some data of the current approval opinions. Users can use it to make decisions, run different business logic, and customize the displayed content.
Parameters
None
Return Value
| Parameter | Description | Type |
|---|---|---|
| entityId | Object apiName | String |
| workflowId | Workflow definition ID | String |
| id | Instance ID | String |
| objectId | Object ID | String |
| tasks | Node content | Array |
| ... | ... | ... |
Code Example
export default class Plugin {
apply() {
return [
{
event: "approval.opinions.render.before",
functional: this.approvalOpinionsRenderBefore.bind(this)
}
]
}
approvalOpinionsRenderBefore(api) {
let opinionsData = api.getOpinionsData();
console.log(opinionsData);
}
}2. setCustomData
Description
Users can customize the approval opinion area, including its content and styles.
Parameters
| Parameter | Description | Type |
|---|---|---|
| content | Custom approval opinion content | Object |
Return Value
None
Code Example
export default class Plugin{
apply(){
return [{
event: "approval.opinions.render.before",
functional: this.approvalOpinionsRenderBefore.bind(this)
}]
}
approvalOpinionsRenderBefore(api){
let originalInstance = api.getOpinionsData()
let instance = JSON.parse(JSON.stringify(originalInstance));
let tasks = instance && instance.tasks;
if(tasks){
tasks.forEach(task=>{
task.stateLabel = 'Custom node status text'
task.stateLabelColor = "#e23451"
let opinions = task && task.opinions;
if(opinions){
opinions.forEach(op=>{
op.stateLabel = 'Assist';
op.stateLabelColor = '#e23451';
op.useCustomOpinion = true;
op.opinion='This opinion was modified by the plugin';
})
}
let parallelGateWayTasks = task.tasks
if(parallelGateWayTasks){
parallelGateWayTasks.forEach(pt=>{
pt.stateLabel = "Parallel node status";
pt.stateLabelColor = '#e23451';
})
}
task.canReply=false;
if(task.state === 'pass'){
task.name="This node has already been completed"
}
});
}
api.setCustomData(instance)
}
}Notes
- This API cannot modify the content of the start node or end node.
- Node data is stored in
opinionsData.tasks. To modify a specific node, iterate throughtasks.
