English
Groovy Code Example
About 221 wordsLess than 1 minute
2026-01-09
This method primarily implements rejection operations through the task completion interface, and can also re-initiate the process to the current node after rejection. The task query approach below can be customized according to specific business requirements. This documentation focuses on:
// Get current data information
String entityId = context.data.object_describe_api_name
String objectId = context.data._id
// Retrieve 20 records (adjustable) of instance information for current data. Statuses: in_progress (processing), pass (completed), cancel (withdrawn), error (exception)
APIResult instanceResult = Fx.approval.findInstances(entityId, ["in_progress"], objectId, 20, 0)
QueryResult instanceQueryResult = instanceResult[1]
instanceQueryResult.getDataList().each{
instance->instance
String instanceId = instance["instanceId"]
// Get all task information through the instance
APIResult taskResult = Fx.approval.findTasks(instanceId)
List tasks = taskResult[1]
tasks.each{
task->task
String currentTaskId = task["taskId"]
Object opinions = task["opinions"]
String state = task["state"]
// Task assignees
List userIds = (List) task["userIds"]
//log.info("Task ID:"+currentTaskId+", current task status:"+state+", approval comments:"+opinions)
// Current task is in progress
if("in_progress"==state){
log.info("currentTaskId:"+currentTaskId)
// Execute rejection operation for current task: task ID, action type, rejection comments, processor (only processors can reject/approve tasks), entity ID, object ID, data (pass null if no update needed), whether to re-initiate to current node (true: yes, false: no)
Fx.approval.approvalAction(currentTaskId, "reject", "Reject and re-initiate to current node", userIds.get(0).toString(), entityId, objectId, null, true)
}
}
}