English
Fx.bpm
About 1650 wordsAbout 6 min
2026-01-09
1. findInstances Find all business flow instances for specified objects and data
Retrieve all business flow instances for specified objects and specified data
Fx.bpm.findInstances(<String objectApiName>, <String state>, <String dataId>, <Integer pageSize>, <Integer pageNumber>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| objectApiName | String | API name of the object | Y |
| state | String | Business flow status | Y |
| dataId | String | Data ID | Y |
| pageSize | Integer | Number of records per page (maximum 100) | Y |
| pageNumber | Integer | Current page number | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| isError | Boolean | Whether an error occurred |
| data | object | |
| message | String | Message |
| data | object | Description |
|---|---|---|
| QueryResult | object |
| QueryResult | object | Description |
|---|---|---|
| total | Integer | Total count |
| dateList | List[object] | Returned data |
| dateList | object | Description |
|---|---|---|
| instanceId | String | Process instance ID |
| workflowName | String | Workflow name |
| state | String | Status |
| applicantId | String | Process initiator |
Return an example
{
"isError": false,
"data": {
"QueryResult": {
"total": 1,
"dateList": [
{
"instanceId": "66f3c627e268c669f62e2a3e",
"workflowName": "Test Workflow",
"state": "in_progress",
"applicantId": "1014"
}
]
}
},
"message": ""
}Code examples
def ret = Fx.bpm.findInstances("object_C6kha__c", "in_progress", "600558de3dacbe000167a1d9", 10, 1)
log.info(ret)Notice
- The state parameter in the input supports the following business flow statuses: in_progress (in progress), pass (passed), cancel (cancelled), and error (exception).
2. findTaskList Query all task nodes in the business flow
Find all task nodes in the business flow
Fx.bpm.findTaskList(<String instanceId>, <Integer pageSize>, <Integer pageNumber>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| instanceId | String | Business process instance ID | Y |
| pageSize | Integer | Number of records per page (maximum 100) | Y |
| pageNumber | Integer | Current page number | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| isError | Boolean | Error status flag |
| data | List[Map] | Response data |
| message | String | Message information |
Return an example
{
"isError": false,
"data": [
{
"taskId": "213312",
"taskName": "Task name here",
"state": "in_progress"
}, {
"taskId": "213312e12",
"taskName": "Task name here 1",
"state": "in_progress"
}
],
"message": ""
}Code examples
def ret = Fx.bpm.findTaskList("600655f76cf582000145d366", 10, 1)
log.info(ret)Notice
- In the input parameters, pageSize represents the number of data items per page, with a maximum support of 100 entries.
3. findTask Retrieve detailed information of a specified node
Retrieve detailed information of a specific node
Fx.bpm.findTask(<String taskId>, <Boolean notGetData>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| taskId | String | Task ID | Y |
| notGetData | Boolean | Skip fetching object data when retrieving workflow editing tasks | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| isError | Boolean | |
| data | object | |
| message | string |
| data | object | Description |
|---|---|---|
| name | String | |
| state | String | |
| applicantId | String | |
| apiName | String | |
| dataId | String | |
| candidateIds | List[String] | |
| processIds | List | |
| activityInstanceIds | List |
Return an example
{
"isError" : false,
"data" : {
"name": "Business Activity",
"state": "in_progress",
"applicantId": "0",
"apiName": "object_k91i0__c",
"dataId": "66f3c5c585821400013bd90e",
"candidateIds": ["1000"],
"processIds": [],
"activityInstanceIds": "0"
},
"message" : ""
}Code examples
def ret = Fx.bpm.findTask("600655f76cf582000145d367", true)
log.info(ret)4. cancel Cancel workflow instance
Cancel Process Instance
Fx.bpm.cancel(<String instanceId>, <String reason>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| instanceId | String | Business process instance ID | Y |
| reason | String | Cancellation reason | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| isError | Boolean | Error status flag |
| data | Map | Response data |
| message | String | Status message |
Return an example
{
"isError" : false,
"data" : {},
"message" : ""
}Code examples
def ret = Fx.bpm.cancel("60058b414349d20001b32aef", "Cancel request")
log.info(ret)5. approval Perform operations on approval nodes (nodes requiring designation of next-node task assignees are not supported)
Perform operations on approval nodes (nodes that require specifying the next node task assignee are not supported)
Fx.bpm.approval(<String taskId>, <String userId>, <String action>, <String opinion>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| taskId | String | Approval task node ID | Y |
| userId | String | Approval processor ID | Y |
| action | String | Approval action type (agree, reject) | Y |
| opinion | String | Approval comments | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| isError | Boolean | Error flag |
| data | Map | Response data |
| message | String | Message |
Return an example
{
"isError" : false,
"data" : {},
"message" : ""
}Code examples
def ret = Fx.bpm.approval("60058bd24349d20001b32af2", "1000", "agree", "Absolutely agree")
log.info(ret)6. complete Perform completion operation on business nodes
Complete the business node operation
Fx.bpm.complete(<string taskId>, <string userId>, <string opinion>, <map map>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| taskId | string | Task ID | Y |
| userId | string | User ID | Y |
| opinion | string | Optional parameter, used together with 'map' to specify processing opinion | Y |
| map | map | Optional parameter, used together with 'opinion' to provide additional parameters | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| isError | Boolean | Indicates whether an error occurred |
| data | Map | Response data |
| message | String | Message information |
Return an example
{
"isError" : false,
"data" : {},
"message" : ""
}Code examples
//The business flow node for selecting or creating an associated object class can be automatically completed via function. The fourth parameter can be set with key:"relatedObjectId" -> value: the ID of the newly created associated object
Map map = ["relatedObjectId": "5e16cc13e4817e0001ee1a3e"]
def ret = Fx.bpm.complete("60058b414349d20001b32af0", "1000", "Approved", map)
log.info(ret)7. changeCandidateIds Replace current node assignees
Change Current Node Handler
Fx.bpm.changeCandidateIds(<String taskId>, <List candidateIds>, <String opinion>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| taskId | String | Task ID | Y |
| candidateIds | List[string] | Candidate handlers for replacement | Y |
| opinion | String | Reason for handler replacement | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| isError | Boolean | Error flag |
| data | null | |
| message | String | Triggered response message |
Return an example
{
"isError": false,
"data": null,
"message": "success!"
}Code examples
def ret = Fx.bpm.changeCandidateIds("600655f76cf582000145d367", [1000, 1001, 1002])
log.info(ret)8. startInstance triggers the business flow
Trigger Business Flow
Fx.bpm.startInstance(<String id>, <String objectId>, <String entityId>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| id | String | Business flow definition ID | Y |
| objectId | String | Object data ID | Y |
| entityId | String | Object API name | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| isError | Boolean | Error status flag |
| data | String | Triggered instance ID |
| message | string |
Return an example
{
"isError": false,
"data": "Triggered instance ID",
"message": ""
}8. Trigger business flow by sourceWorkflowId
Trigger Business Flow
Fx.bpm.start(<String sourceWorkflowId>, <String objectId>, <String entityId>)
Request parameters
Request Body
| Parameter Name | Trigger Business Process via sourceWorkflowId | Description | Required |
|---|---|---|---|
| sourceWorkflowId | String | Business flow sourceWorkflowId | Y |
| objectId | String | Object data ID | Y |
| entityId | String | Object API name | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| isError | Boolean | Error flag |
| data | String | Triggered instance ID |
| message | string |
Return an example
{
"isError": false,
"data": "Triggered instance ID",
"message": ""
}Code examples
/**
* @author Cui Yongxu
* @codeName triggerBpm
* @description triggerBpm
* @createTime 2025-03-12
* @bindingObjectLabel
* @bindingObjectApiName object_Yw3f8__c
* @functionRequirementID
*/
String objectId = context.data._id
String entityId = context.data.object_describe_api_name
def result = Fx.bpm.start( "67d148372602fe00017f1ad5", objectId,entityId)
log.info(result)9. getDefinitionList Retrieve Business Flow Definition List
Get Business Flow Definition List
Fx.bpm.getDefinitionList(<String entityId>, <Integer page>, <Integer pageSize>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| entityId | String | Object ApiName | Y |
| page | Integer | Page number | Y |
| pageSize | Integer | Query quantity | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| isError | Boolean | Indicates whether an error occurred |
| data | Map[object] | Definition list |
| message | string |
| data | object | Description |
|---|---|---|
| id | String | Workflow definition ID |
| sourceWorkflowId | String | Workflow version definition ID |
| workflowName | String | Workflow definition name |
Return an example
{
"isError": false,
"data": [
{
"id": "Workflow Definition ID 1",
"sourceWorkflowId": "Workflow Version Definition ID 1",
"workflowName": "Workflow Definition Name 1"
},
{
"id": "Workflow Definition ID 2",
"sourceWorkflowId": "Workflow Version Definition ID 2",
"workflowName": "Workflow Definition Name 2"
}
],
"message": ""
}Code examples
// Get definition by object ApiName
def(Boolean error, Map data, String message) = Fx.bpm.getDefinitionList("FundReturnBackObj", 1, 10)
if(false == error){
// Get definition list
List item = data['data'] as List
item.each{
// Get related definitions by workflow name
i ->if('Definition obtained by function' == i['workflowName']){
// Trigger business flow
Fx.bpm.startInstance(i['id'] as String, '62c39d5d71f9010001ae0ea9', 'FundReturnBackObj')
}
}
}10. delayTaskImmediatelyExecute Business flow wait node immediate execution
Business flow wait node immediate execution
Fx.bpm.delayTaskImmediatelyExecute(<String taskId>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| taskId | String | Task ID | Y |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| isError | Boolean | Indicates whether an error occurred |
| data | Map | Response data |
| message | String | Message information |
Return an example
{
"isError" : false,
"data" : {},
"message" : ""
}Code examples
APIResult res = Fx.bpm.delayTaskImmediatelyExecute("62f320a7c6fa24292be4f830");
if(res.isError() || res.message() != ""){
log.info(res.message())
}else{
log.info("Business flow automatic node executed successfully immediately")
}11. refreshHandler Re-parse task handler
Reparse task handler
Fx.bpm.refreshHandler(<String taskId>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| taskId | String | Task ID | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| isError | Boolean | Indicates whether an error occurred |
| data | object | |
| message | string |
Return an example
{
"isError": false,
"data": {},
"message": ""
}Code examples
def taskId = "6343e4d780f4841c79cbcae0"
def res = Fx.bpm.refreshHandler(taskId)
log.info(res)11. operate operation tasks
Operation Tasks (Pause/Resume/Forward Sign)
Fx.bpm.operate(<String taskId>, <String type>, <String opinion>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| taskId | String | Task ID | Y |
| type | String | Operation type; suspend - pause task; resume - resume task; | Y |
| opinion | String | Opinion | -- |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| errorMessage | string | Error message |
Return an example
{
"errorMessage": "The current task cannot be paused, please refresh the page"
}Code examples
def taskId = "684ba0ac71dd2917daf12048"
def type = "suspend"
def(Boolean error, Map data, String errorMessage) = Fx.bpm.operate(taskId, type, null, null)
if(error) {
log.info(errorMessage)
}12. findDelayTask Retrieve pending nodes by objectId or workflowInstanceId
Retrieve pending nodes by objectId or workflowInstanceId
Fx.bpm.findDelayTask(<String objectId>, <String workflowInstanceId>, <Integer pageNumber>, <Integer pageSize>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| objectId | String | Data ID | Y |
| workflowInstanceId | String | Workflow instance ID | Y |
| pageNumber | Integer | Page number for query | Y |
| pageSize | Integer | Number of items per page | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| isError | Boolean | Whether an error occurred |
| data | Map[object] | Task list |
| message | string |
| data | object | Description |
|---|---|---|
| id | String | Task ID |
| name | String | Task name |
| state | String | Task status |
Return an example
{
"isError": false,
"data": [
{
"id": "task_id1",
"name": "Task 1",
"state": "in_progress"
},
{
"id": "task_id2",
"name": "Task 2",
"state": "error"
}
],
"message": ""
}Code examples
def objectId = "63a403eb314aa80001bd9b82"
def instanceId = "63a405d45513f84c58c2b66c"
Integer pageNumber = 1
Integer pageSize = 3
// Query delayed tasks by data ID
def(Boolean err1, Map data1, String msg1) = Fx.bpm.findDelayTask(objectId, null, pageNumber, pageSize)
if (err1) {
log.info("error: " + msg1)
} else {
log.info(data1)
}
// Query delayed tasks by instance ID
def(Boolean err2, Map data2, String msg2) = Fx.bpm.findDelayTask(null, instanceId, pageNumber, pageSize)
if (err2) {
log.info("error: " + msg2)
} else {
log.info(data2)
}