English
Fx.approval
About 5656 wordsAbout 19 min
2026-01-09
1. findInstances returns all approval instances for the specified object and optional specified data
Retrieve all approval instances for the specified object and optional specified data
Fx.approval.findInstances(<String entityId>, <List<String> state>, <String objectId>, <Integer limit>, <Integer skip>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| entityId | String | Associated object | Y |
| state | List<String> | Process status. in_progress: In progress; pass: Completed; cancel: Withdrawn; reject: Rejected | Y |
| objectId | String | Data ID | Y |
| limit | Integer | Number of records required | Y |
| skip | Integer | Starting index for data retrieval | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| error | boolean | Indicates whether an exception exists |
| data | object | Result data |
| errorMessage | string | Error message returned when exception occurs |
| data | object | Result data |
|---|---|---|
| size | integer | Number of returned data items in current response |
| total | integer | Total number of data items |
| dataList | array[object] | Result set |
| dataList | object | Description |
|---|---|---|
| owner | array[string] | Process initiator |
| submitter | array[string] | Process submitter |
| instanceId | string | Instance ID |
| dataId | string | Data ID |
| createTime | integer | Process initiation time |
| approvalApiName | string | Primary version of process definition |
| approvalName | string | Process definition name |
| endTime | integer | Process completion time |
Return an example
{
"error": false,
"data": {
"size": 1,
"total": 1,
"dataList": [
{
"owner": [
"1002"
],
"submitter": [
"1002"
],
"instanceId": "66f2a4856b07ab1b4ebad7e5",
"dataId": "66f2a484928b280007aa6dd8",
"createTime": 1727177862204,
"approvalApiName": "apprZVJ6E46RHG__crmappr",
"approvalName": "Approval Flow - Subprocess Usage",
"endTime": 0
}
]
},
"errorMessage": ""
}Code examples
QueryResult queryResult = Fx.approval.findInstances((String) context.data.object_describe_api_name, ["in_progress"], (String) context.data._id, 10, 0)[1];
log.info(queryResult)
if (queryResult != null) {
// Retrieve in-progress approval flow instances (by default there should be only one active instance)
List dataList = (List) queryResult["dataList"]
def instance = dataList[0]
log.info("instance:" + instance)
} else {
log.info("No approval flow instance found for current data, please check configuration parameters")
}2. findInstances Query approval instances on an object (Note: The query is not real-time and has a delay. For real-time queries, please refer to the Lexiang article: Functions for Real-time Approval Flow Queries)
Query approval instances on an object (Note: The query is not real-time and has a delay. For real-time queries, please refer to the LeShare article: Functions for Real-time Approval Flow Queries)
Fx.approval.findInstances(<String entityId>, <List<String> state>, <String objectId>, <Integer limit>, <Integer skip>, <ActionAttribute attribute>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| entityId | String | Associated object | Y |
| state | List<String> | Process status. in_progress: Ongoing; pass: Completed; cancel: Withdrawn; reject: Rejected | Y |
| objectId | String | Data ID | Y |
| limit | Integer | Number of records required | Y |
| skip | Integer | Starting index for data retrieval | Y |
| attribute | ActionAttribute | Attribute settings for current operation | -- |
| attribute | ActionAttribute | Attribute settings for current operation | Required |
|---|---|---|---|
| forceQueryFromDB | Boolean | Whether to force query from database (default: false) | -- |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| error | boolean | Indicates whether an exception exists |
| data | object | Result data |
| errorMessage | string | Error message returned when exception occurs |
| data | object | Result data |
|---|---|---|
| size | integer | Number of returned data items in current response |
| total | integer | Total number of data items |
| dataList | array[object] | Result set |
| dataList | object | Description |
|---|---|---|
| owner | array[string] | Process initiator |
| submitter | array[string] | Process submitter |
| instanceId | string | Instance ID |
| dataId | string | Data ID |
| createTime | integer | Process initiation timestamp |
| approvalApiName | string | Primary version of process definition |
| approvalName | string | Process definition name |
| endTime | integer | Process completion timestamp |
Return an example
{
"error": false,
"data": {
"size": 1,
"total": 1,
"dataList": [
{
"owner": [
"1002"
],
"submitter": [
"1002"
],
"instanceId": "66f2a4856b07ab1b4ebad7e5",
"dataId": "66f2a484928b280007aa6dd8",
"createTime": 1727177862204,
"approvalApiName": "apprZVJ6E46RHG__crmappr",
"approvalName": "Approval Workflow - Subprocess Usage",
"endTime": 0
}
]
},
"errorMessage": ""
}Code examples
ActionAttribute attribute = ActionAttribute.build {
forceQueryFromDB = false
}
QueryResult queryResult = Fx.approval.findInstances((String) context.data.object_describe_api_name, ["in_progress"], (String) context.data._id, 10, 0, attribute)[1];
log.info(queryResult)
if (queryResult != null) {
//Retrieve in-progress approval flow instances (by default there should be only one active instance)
List dataList = (List) queryResult["dataList"]
def instance = dataList[0]
log.info("instance:" + instance)
} else {
log.info("No approval flow instance found for current data, please check configuration parameters")
}3. findInstances Query approval instances on an object
Query ongoing approval processes for a specific object
Fx.approval.findInstances(<string entityId>, <integer limit>, <integer skip>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| entityId | string | Parent entity ID | Y |
| limit | integer | Number of records to fetch | Y |
| skip | integer | Starting offset for data retrieval | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| error | boolean | Indicates whether an exception exists |
| data | object | Result data |
| errorMessage | string | Error message returned when exception occurs |
| data | object | Result data |
|---|---|---|
| size | integer | Number of returned data items in current response |
| total | integer | Total number of data items |
| dataList | array[object] | Result set |
| dataList | object | Description |
|---|---|---|
| owner | array[string] | Process initiator |
| submitter | array[string] | Process submitter |
| instanceId | string | Instance ID |
| dataId | string | Data ID |
| createTime | integer | Process initiation time |
| approvalApiName | string | Primary version of process definition |
| approvalName | string | Process definition name |
| endTime | integer | Process completion time |
Return an example
{
"error": false,
"data": {
"size": 1,
"total": 1,
"dataList": [
{
"owner": [
"1002"
],
"submitter": [
"1002"
],
"instanceId": "66f2a4856b07ab1b4ebad7e5",
"dataId": "66f2a484928b280007aa6dd8",
"createTime": 1727177862204,
"approvalApiName": "apprZVJ6E46RHG__crmappr",
"approvalName": "Approval Workflow - Subprocess Usage",
"endTime": 0
}
]
},
"errorMessage": ""
}Code examples
QueryResult queryResult = Fx.approval.findInstances((String) context.data.object_describe_api_name, 10, 0)[1];
log.info(queryResult)Notice
- Limit the number of query results, with a maximum of 100 records per query.
4. findTasks Query all approval task nodes under an approval instance (Note: The query is not real-time and has a delay)
Query all approval task nodes under an approval instance
Fx.approval.findTasks(<string instanceId>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| instanceId | string | Instance ID | Y |
Return Parameters
| Parameter Name | object | Result |
|---|---|---|
| error | boolean | Whether an error occurred |
| result | array[object] | Result set |
| errorMessage | string | Error message |
| result | object | Task list |
|---|---|---|
| taskId | string | Task ID |
| dataId | string | Data ID |
| objectApiName | string | Object API name |
| createTime | integer | Creation timestamp |
| duration | integer | Task duration |
| userIds | array[string] | Task assignees (this field remains unchanged during task processing and only updates when assignees are modified) |
| type | string | Task type: 'one_pass' or 'single' for single/multi-person approval; 'all_pass' for joint approval |
| state | string | Task status: 'pass' for approved, 'reject' for rejected, 'cancel' for withdrawn, 'error' for exception |
| opinions | array[object] | Approval comments |
| task_name | string | Task name |
| dealed_persons | array[string] | Processed persons (this field updates after task processing. For joint approval nodes, it updates after each processing) |
| workflow_instance_id | string | Workflow instance ID |
| submitter | array[string] | Data submitter |
| workflow_id | string | Workflow sub-version ID |
| is_timeout | boolean | Whether timeout occurred (default: null) |
| opinions | object | Description |
|---|---|---|
| userId | integer | Handler ID |
| actionType | string | Processing result: 'agree' for approved, 'reject' for rejected, 'cancel' for withdrawn, 'addTag' for pre-endorsement, 'retrieve' for retrieval and re-review, 'auto_pass' or 'auto_agree' for auto-approval, 'tagAfter' for post-endorsement, 'skip_task_validate' for skipping task completion conditions and post-task actions |
| opinion | string | Approval comment |
| replyTime | integer | Processing timestamp |
Return an example
{
"error": false,
"result": [
{
"taskId": "66f656c1deb560342dbd4381",
"dataId": "66f656c125255b00077a168c",
"objectApiName": "object_RlhY0__c",
"createTime": 1727420105143,
"duration": 6769,
"userIds": [
"1007"
],
"type": "one_pass",
"state": "pass",
"opinions": [
{
"userId": 1007,
"actionType": "agree",
"opinion": "Approved.",
"replyTime": 1727335044325
}
],
"task_name": "A",
"dealed_persons": [
"1007"
],
"workflow_instance_id": "66f656c10cf87e114caaa80a",
"submitter": [
"1007"
],
"workflow_id": "66f655490cf87e114caaa7fd",
"is_timeout": false
}
],
"errorMessage": ""
}Code examples
String entityId = (String) context.data.object_describe_api_name
String objectId = (String) context.data._id
def instanceId = Fx.approval.existsInstance(entityId, objectId).result()
log.info("instanceId:"+instanceId)
def tasks = Fx.approval.findTasks((String)instanceId)
log.info(tasks)5. cancelApproval Specify the target object and data ID to revoke an ongoing approval process
Specify the object and data ID to revoke an ongoing approval process
Fx.approval.cancelApproval(<String entityId>, <String objectId>, <String cancelReason>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| entityId | String | Owning entity | Y |
| objectId | String | Owning data | Y |
| cancelReason | String | Cancellation reason | -- |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| error | Boolean | Whether an error occurred |
| data | void | No return value |
| errorMessage | String | Error message |
Return an example
{
"error":false,
"data":null,
"errorMessage":""
}Code examples
String entity_id = context.data.object_describe_api_name
String object_id = context.data._id
log.info(entity_id + ":" + object_id)
def ret = Fx.approval.cancelApproval(entity_id, object_id, "Withdraw approval process")
log.info(ret)6. approvalAction Perform operations on approval task nodes
Perform operations on approval nodes/task nodes
Fx.approval.approvalAction(<string taskId>, <string actionType>, <string opinion>, <string userId>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| taskId | string | Task ID | Y |
| actionType | string | Action type. agree: Approve; reject: Reject | Y |
| opinion | string | Approval comments | -- |
| userId | string | Arbitrary approver ID | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| error | boolean | Indicates whether an exception exists |
| result | object | No return result |
| errorMessage | string | Exception message |
Return an example
{
"error": false,
"result": "66f656c10cf87e114caaa80a",
"errorMessage": ""
}Code examples
// The approval flow is set as: Single Approver A -> Single Approver B -> Single Approver C
// In this case, the approval has reached Single Approver C
String entityId = (String) context.data.object_describe_api_name
String objectId = (String) context.data._id
def instanceId = Fx.approval.existsInstance(entityId, objectId).result()
log.info("instanceId:" + instanceId)
def tasks = Fx.approval.findTasks((String)instanceId)
//log.info(tasks)
def taskList = tasks.get(1) as List
// Retrieve one of the tasks
Map task = taskList[0] as Map
log.info(task)
String taskId = task["taskId"]
List candidateIds = task["userIds"]
// agree or reject
def ret = Fx.approval.approvalAction(taskId, "agree", "Approved", (String)candidateIds[0])Notice
- If the task involves process layout or custom layout, this method is not recommended as it cannot properly handle form data. It is advised to use this method only when there is no form information involved.
7. setApprovalIds Replace approvers for approval task nodes
Change the approver of the approval task node
Fx.approval.setApprovalIds(<string taskId>, <array candidateIds>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| taskId | string | Task ID | Y |
| candidateIds | array[string] | Task assignees | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| error | boolean | Indicates whether an error exists |
| result | object | No return result |
| errorMessage | string | Error message |
Return an example
{
"error": false,
"result": null,
"errorMessage": ""
}Code examples
String entityId = (String) context.data.object_describe_api_name
String objectId = (String) context.data._id
def instanceId = Fx.approval.existsInstance(entityId, objectId).result()
log.info("instanceId:"+instanceId)
def tasks = Fx.approval.findTasks((String)instanceId)
log.info(tasks)
def taskList = tasks.get(1) as List
// Get one of the tasks
Map task = taskList[0] as Map
log.info(task)
String taskId = task["taskId"]
log.info(taskId)
// Change task assignee
def result = Fx.approval.setApprovalIds(taskId, ["1000","1011","1012"])
log.info(result)Notice
- The handler replacement is performed under the system identity (-10000). Therefore, after the replacement is completed, the task handler modification log will display that the handler was changed by the system.
8. getCanRefuseTasks Query the task node information that can be rejected back through the current instance
Query information about task nodes that can be rejected through the current instance.
Fx.approval.getCanRefuseTasks(<string instanceId>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| instanceId | string | Instance ID | Y |
Return Parameters
| Parameter Name | object | Result item |
|---|---|---|
| taskId | string | Task ID |
| taskFullName | string | Task name |
| enableMoveToCurrentActivityWhenReject | boolean | New field added in v9.3.0. When rejecting to this task, determines whether the workflow returns to the original node after processing. If true, allows rejection to a predecessor node, which will return to the original node after processing |
Return an example
[
{
"taskId": "66f52985deb560342dbd3e21",
"taskFullName": "A",
"enableMoveToCurrentActivityWhenReject": false
}
]Code examples
String entityId = (String) context.data.object_describe_api_name
String objectId = (String) context.data._id
def instanceId = Fx.approval.existsInstance(entityId, objectId).result()
log.info("instanceId:" + instanceId)
def canRefuseTasks = Fx.approval.getCanRefuseTasks((String) instanceId)
log.info(canRefuseTasks)Notice
- In the case of a parallel gateway where multiple ongoing tasks exist simultaneously, if no task ID is provided, the system will randomly retrieve any one of the tasks that can be rejected to a node by default. It is recommended to use
Fx.approval.getCanRefuseTasks(instanceId, task)for retrieval.
9. getCanRefuseTasks Query the task node information that can be rejected through the current instance
Retrieve the task node information that can be rejected to, using the current instance ID and current task ID.
Fx.approval.getCanRefuseTasks(<string instanceId>, <string taskId>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| instanceId | string | Instance ID | Y |
| taskId | string | Task ID | Y |
Return Parameters
| Parameter Name | object | Result item |
|---|---|---|
| taskId | string | Task ID |
| taskFullName | string | Task name |
| enableMoveToCurrentActivityWhenReject | boolean | New field added in v9.3.0. When rejecting to this task, determines whether the workflow should return to the original node after this task is processed. If true, allows rejection to a predecessor node with automatic return to the original node after processing. |
Return an example
[
{
"taskId": "66f52985deb560342dbd3e21",
"taskFullName": "A",
"enableMoveToCurrentActivityWhenReject": false
}
]Code examples
String entityId = (String) context.data.object_describe_api_name
String objectId = (String) context.data._id
def instanceId = Fx.approval.existsInstance(entityId, objectId).result()
log.info("instanceId:"+instanceId)
String taskId = "66f656f7deb560342dbd4394"
def canRefuseTasks = Fx.approval.getCanRefuseTasks((String)instanceId,taskId)
log.info(canRefuseTasks)10. getDetailChange Retrieve object change details
Retrieve Object Change Details
Fx.approval.getDetailChange(<string instanceId>, <string detailEntityId>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| instanceId | string | Instance ID | Y |
| detailEntityId | string | Subordinate object API name | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| data | object | |
| describe | object | Subordinate object description |
| detailDisplayName | string | Subordinate object name |
| describeExt | object | Extended information of subordinate object description |
| data | object | Description |
|---|---|---|
| Add | array | Newly added subordinate object data, complete dataset |
| Delete | array[object] | Deleted subordinate object data |
| Edit | array[object] | Number of subordinate data items added |
| Delete | object | Description |
|---|---|---|
| detailDataId | string | Subordinate object data ID |
| detailDataName | string | Subordinate object name - primary attribute of subordinate object |
| recordType | string | Business type |
| Edit | object | Description |
|---|---|---|
| detailDataId | string | Subordinate object data ID (may not exist for new additions) |
| detailDataName | string | BusinessType_SubordinateObjectChineseName_PrimaryAttribute |
| recordType | string | Business type |
| fieldChangeDetail | array[object] |
| fieldChangeDetail | object | Description |
|---|---|---|
| newValue | string | Previous field value when editing subordinate data |
| fieldApiName | string | Field API name |
| oldValue | string | Modified value when editing subordinate data |
Return an example
{
"data": {
"Add": [
{
"tenant_id": "71557",
"lock_rule": "default_lock_rule",
"data_own_organization": [
"999999"
],
"data_own_organization__l": [
{
"deptName": "Entire Organization",
"leaderUserId": "1034",
"deptId": "999999",
"deptType": "org",
"status": 0
}
],
"__new_data__": true,
"mc_exchange_rate": "1.000000",
"field_gM81p__c__r": {
"deptName": "Test Secondary Department",
"leaderUserId": "1099",
"deptId": "1027",
"deptType": "dept",
"parentId": "1026",
"status": 0
},
"created_by__r": {
"picAddr": "N_201907_10_5ba561a111724c3c8232b68bed4c2077",
"description": "",
"dept": "1017",
"empNum": "1007",
"modifyTime": 1726824651698,
"post": "R&D Engineer",
"createTime": 1524219762800,
"phone": "01090102910",
"name": "Cui Yongxu-CN",
"nickname": "Cui Yongxu-CN",
"tenantId": "71557",
"id": "1007",
"email": "cuiyx@fxiaoke.com",
"status": 0
},
"field_C38fh__c": "444",
"data_own_organization__r": {
"deptName": "Entire Organization",
"leaderUserId": "1034",
"deptId": "999999",
"deptType": "org",
"status": 0
},
"dataIndex": 3,
"field_5zo7k__c": "4444",
"object_describe_api_name": "object_p2Eps__c",
"owner__l": [
{
"picAddr": "N_201907_10_5ba561a111724c3c8232b68bed4c2077",
"description": "",
"dept": "1017",
"modifyTime": 1726824651698,
"empNum": "1007",
"post": "R&D Engineer",
"phone": "01090102910",
"createTime": 1524219762800,
"tenantId": "71557",
"name": "Cui Yongxu-CN",
"nickname": "Cui Yongxu-CN",
"id": "1007",
"email": "cuiyx@fxiaoke.com",
"status": 0
}
],
"field_QwvF2__c": "66f66d5725255b0007876946",
"field_QwvF2__c__r": "Tathagata-2024-09-27279",
"mc_functional_currency": "CNY",
"owner__r": {
"picAddr": "N_201907_10_5ba561a111724c3c8232b68bed4c2077",
"description": "",
"dept": "1017",
"empNum": "1007",
"modifyTime": 1726824651698,
"post": "R&D Engineer",
"createTime": 1524219762800,
"phone": "01090102910",
"name": "Cui Yongxu-CN",
"nickname": "Cui Yongxu-CN",
"tenantId": "71557",
"id": "1007",
"email": "cuiyx@fxiaoke.com",
"status": 0
},
"__tbIndex": 4,
"field_j2w1H__c": "33",
"field_gM81p__c__l": [
{
"deptName": "Test Secondary Department",
"leaderUserId": "1099",
"deptId": "1027",
"deptType": "dept",
"parentId": "1026",
"status": 0
}
],
"owner": [
"1007"
],
"field_289O2__c": "33",
"lock_status": "0",
"data_own_department__r": {
"deptName": "Seventh-level Department",
"leaderUserId": "1007",
"deptId": "1017",
"deptType": "dept",
"parentId": "1016",
"status": 0
},
"create_time": 1727425931205,
"field_gM81p__c": [
"1027"
],
"life_status": "in_change",
"last_modified_by__l": [
{
"picAddr": "N_201907_10_5ba561a111724c3c8232b68bed4c2077",
"description": "",
"dept": "1017",
"modifyTime": 1726824651698,
"empNum": "1007",
"post": "R&D Engineer",
"phone": "01090102910",
"createTime": 1524219762800,
"tenantId": "71557",
"name": "Cui Yongxu-CN",
"nickname": "Cui Yongxu-CN",
"id": "1007",
"email": "cuiyx@fxiaoke.com",
"status": 0
}
],
"created_by__l": [
{
"picAddr": "N_201907_10_5ba561a111724c3c8232b68bed4c2077",
"description": "",
"dept": "1017",
"modifyTime": 1726824651698,
"empNum": "1007",
"post": "R&D Engineer",
"phone": "01090102910",
"createTime": 1524219762800,
"tenantId": "71557",
"name": "Cui Yongxu-CN",
"nickname": "Cui Yongxu-CN",
"id": "1007",
"email": "cuiyx@fxiaoke.com",
"status": 0
}
],
"last_modified_by": [
"1007"
],
"display_name": "default__c____",
"__operateWidth": 88,
"created_by": [
"1007"
],
"mc_currency": "CNY",
"record_type": "default__c",
"field_7s7Gg__c": "33",
"last_modified_by__r": {
"picAddr": "N_201907_10_5ba561a111724c3c8232b68bed4c2077",
"description": "",
"dept": "1017",
"empNum": "1007",
"modifyTime": 1726824651698,
"post": "R&D Engineer",
"createTime": 1524219762800,
"phone": "01090102910",
"name": "Cui Yongxu-CN",
"nickname": "Cui Yongxu-CN",
"tenantId": "71557",
"id": "1007",
"email": "cuiyx@fxiaoke.com",
"status": 0
},
"rowId": "17274259128251754",
"data_own_department": [
"1017"
],
"field_sg0sY__c": "33",
"object_describe_id": "5b8e55a7a5083d5ecf5d8b66",
"name": "Data 1",
"order_by": 40,
"mc_exchange_rate_version": "1716450563496",
"_id": "66f66d8b25255b000787c759",
"data_own_department__l": [
{
"deptName": "Seventh-level Department",
"leaderUserId": "1007",
"deptId": "1017",
"deptType": "dept",
"parentId": "1016",
"status": 0
}
]
}
],
"Delete": [
{
"detailDataId": "66f66d5725255b0007876949",
"detailDataName": "Sun Wukong-2024-09-272445",
"recordType": "default__c"
}
],
"Edit": [
{
"detailDataId": "66f66d5725255b0007876947",
"detailDataName": "default__c____Sun Wukong-2024-09-272443",
"recordType": "default__c",
"fieldChangeDetail": [
{
"newValue": "5555",
"fieldApiName": "field_289O2__c",
"oldValue": "77"
}
]
}
]
},
"describe": {
"description": "Description too large, omitted here"
},
"detailDisplayName": "Sun Wukong (INAG)",
"describeExt": {
"description": "Description too large, omitted here"
}
}Code examples
String entityId = (String) context.data.object_describe_api_name
String objectId = (String) context.data._id
def instanceId = Fx.approval.existsInstance(entityId, objectId).result()
log.info("instanceId:"+instanceId)
//From object API name
String detailEntityId= "object_p2Eps__c"
def detailDatas = Fx.approval.getDetailChange((String)instanceId,detailEntityId)
log.info(detailDatas)Notice
- Only edit triggers can obtain change information from the object
11. rejectToBeforeTask Reject to any previous node (nodes before the current node)
Reject to any previous node (nodes before the current node)
Fx.approval.rejectToBeforeTask(<string currentTaskId>, <string beforeTaskId>, <string userId>, <string opinion>, <boolean enableMoveToCurrentActivityWhenReject>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| currentTaskId | string | Current task ID | Y |
| beforeTaskId | string | The target task to reject to. Must use tasks returned by Fx.approval.getCanRefuseTasks(instanceId,taskId) API, cannot be arbitrarily specified | Y |
| userId | string | Any handler of the current task | Y |
| opinion | string | Rejection comment | -- |
| enableMoveToCurrentActivityWhenReject | boolean | When true, allows manually selecting to reject to a previous node, which will return to current node after processing. When false, workflow will continue sequentially after previous node processing. | |
| This value must align with enableMoveToCurrentActivityWhenReject returned by Fx.approval.getCanRefuseTasks(instanceId,taskId) API. If the API returns false, passing true to Fx.approval.rejectToBeforeTask will have no effect. Only when API returns true can you choose to reject to previous node and return to current node after processing | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| error | boolean | Indicates whether an exception exists |
| result | object | No return result |
| errorMessage | string | Error message |
Return an example
{
"error": false,
"result": "66f656c10cf87e114caaa80a",
"errorMessage": ""
}Code examples
// The approval flow is set as: Single Approver A -> Single Approver B -> Single Approver C
// In this case, the approval has reached Single Approver C
String entityId = (String) context.data.object_describe_api_name
String objectId = (String) context.data._id
def instanceId = Fx.approval.existsInstance(entityId, objectId).result()
log.info("instanceId:"+instanceId)
def tasks = Fx.approval.findTasks((String)instanceId)
//log.info(tasks)
def taskList = tasks.get(1) as List
// Retrieve one of the tasks
Map task = taskList[0] as Map
log.info(task)
String taskId = task["taskId"]
List candidateIds = task["userIds"]
List<Map<String,Object>> canRefuseTasks = Fx.approval.getCanRefuseTasks((String)instanceId,taskId).result() as List
//log.info(canRefuseTasks)
Map<String,Object> beforeTask = [:]
canRefuseTasks.each{
item->
if(item["taskFullName"]=="Single Approver A"){
beforeTask= item
}
}
log.info(beforeTask)
String beforeTaskId = beforeTask["taskId"]
// enableMoveToCurrentActivityWhenReject: If rejected to `Single Approver A`, whether to return to the current node after `Single Approver A` processes it
// If this value is false, after `Single Approver A` processes it, it cannot return to the current node. Even if true is passed, it will not take effect.
// If this value is true, you can choose whether to return to the current node after `Single Approver A` processes it.
boolean enableMoveToCurrentActivityWhenReject = beforeTask["enableMoveToCurrentActivityWhenReject"]
Fx.approval.rejectToBeforeTask(taskId, beforeTaskId, (String)candidateIds[0], "Reject to the previous node: Single Approver A", enableMoveToCurrentActivityWhenReject)Notice
- If a task node has completion conditions set, currently no exception information will be returned. The observed phenomenon is that although the rejection is executed, the task remains unprocessed. This interface needs to be used in conjunction with Fx.approval.getCanRefuseTasks(instanceId, taskId).
12. skipValidateAndCompleteTask supports full-process event configuration, completes the task, and skips validation and subsequent action execution.
Supports full-process event configuration, completes tasks, and skips validation and post-action execution.
Fx.approval.skipValidateAndCompleteTask(<string taskId>, <string opinion>, <string userId>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| taskId | string | Task ID | -- |
| opinion | string | Processing opinion | -- |
| userId | string | Randomly select one user from the pending processors for validation (skip authentication) to verify if the current user belongs to the task processors | -- |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| error | boolean | Whether an exception exists |
| result | object | No return result |
| errorMessage | string | Error message |
Return an example
{
"error": false,
"result": null,
"errorMessage": ""
}Code examples
String entityId = (String) context.data.object_describe_api_name
String objectId = (String) context.data._id
def instanceId = Fx.approval.existsInstance(entityId, objectId).result()
log.info("instanceId:"+instanceId)
def tasks = Fx.approval.findTasks((String)instanceId)
log.info(tasks)
def taskList = tasks.get(1) as List
// Retrieve one task
Map task = taskList[0] as Map
log.info(task)
String taskId = task["taskId"]
// Get task assignees
List candidateIds = task["userIds"]
// Skip validation and complete task as system identity (bypassing completion conditions and post-task actions). Requires passing any pending task assignee.
def result = Fx.approval.skipValidateAndCompleteTask( taskId, "Skip current task", (String)candidateIds[0])
log.info(result)Notice
- Bypass task completion conditions and post-task actions as system identity
13. delayTaskImmediatelyExecute Approval flow waiting node immediate execution
Approval Flow Wait Node Immediate Execution
Fx.approval.delayTaskImmediatelyExecute(<string operationType>, <string taskId>, <string type>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| operationType | string | Operation type. reflush: Refresh (when the waiting duration is specified as a field, can be invoked if parsing the waiting duration fails); execute: Immediate execution | Y |
| taskId | string | Task ID | Y |
| type | string | Process type, pass 'approvalflow' | Y |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| error | Boolean | Whether an error occurred |
| data | void | No return value |
| errorMessage | String | Error message |
Return an example
{
"error":false,
"data":null,
"errorMessage":""
}Code examples
def res = Fx.approval.delayTaskImmediatelyExecute("62f3217ac6fa24292be4f833").result() as Map;14. existsInstance Checks whether an approval flow has instances. Returns the instance ID if any exists.
Check if an approval flow instance exists, and return the instance ID if it does.
Fx.approval.existsInstance(<string entityId>, <string objectId>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| entityId | string | Parent entity | Y |
| objectId | string | Data ID | Y |
Return Parameters
| Parameter Name | object | Result |
|---|---|---|
| error | boolean | Indicates whether an exception occurred |
| result | string | Returns the instance ID if there is a running instance |
| errorMessage | string | Returns error message if an exception occurred |
Return an example
{
"error": false,
"result": "66f656c10cf87e114caaa80a",
"errorMessage": ""
}Code examples
String entityId = (String) context.data.object_describe_api_name
String objectId = (String) context.data._id
log.info(entityId)
log.info(objectId)
def rst = Fx.approval.existsInstance(entityId, objectId).result()
log.info("instanceId:"+rst)15. refreshHandler Re-parse task handler
Re-parse approver in workflow task processing
Fx.approval.refreshHandler(<string taskId>)
Request parameters
Request Body
| Parameter Name | object | Reparse approver assignment in workflow tasks | Required |
|---|---|---|---|
| taskId | string | Task handler | Y |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| error | Boolean | Whether an error occurred |
| data | void | No return value |
| errorMessage | String | Error message |
Return an example
{
"error":false,
"data":null,
"errorMessage":""
}Code examples
def res = Fx.approval.refreshHandler("66f29d016b07ab1b4ebad554")
log.info(res)Notice
- If the task has an assignee, calling this interface will still trigger secondary parsing and generate modification records for the assignee.
16. findDelayTask Query pending nodes by objectId or approval InstanceId
Query pending nodes by objectId or approval InstanceId
Fx.approval.findDelayTask(<string objectId>, <string workflowInstanceId>, <integer pageNumber>, <integer pageSize>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| objectId | string | Data ID. When objectId is provided, workflowInstanceId becomes optional | -- |
| workflowInstanceId | string | Workflow instance ID. When workflowInstanceId is provided, objectId becomes optional | -- |
| pageNumber | integer | Page number (starting from 1) | Y |
| pageSize | integer | Page size (default: 20) | Y |
Return Parameters
| Parameter Name | object | Result |
|---|---|---|
| error | boolean | Whether an error occurred |
| data | array[object] | Data |
| errorMessage | string | Error message |
| data | object | Pending node result set |
|---|---|---|
| id | string | Task ID |
| tenantId | string | Current enterprise ID |
| appId | string | Default CRM |
| name | string | Task name |
| workflowId | string | Process definition sub-version ID |
| workflowInstanceId | string | Process instance ID |
| activityId | string | Task node ID |
| activityInstanceId | string | Task node instance ID |
| createTime | integer | Creation time |
| modifyTime | integer | Modification time |
| state | string | Task status. pass: approved, cancel: withdrawn, error: exception |
| type | string | Default: executionTask |
| taskType | string | Default: executionTask |
| actionType | string | Reserved |
| description | string | Task description |
| executionList | array[object] | Post-node action list |
| entityId | string | Owning entity |
| objectId | string | Owning data ID |
| latencyTime | string | Waiting duration |
| latencyUnit | string | Time unit: 1: day; 2: hour; 3: minute |
| sourceWorkflowId | string | Process master version number |
| executeTime | integer | Execution time |
| finishedTime | integer | Specific execution time |
| executor | string | Executor. Default is system (-10000). If manually executed, shows specific person |
| delay | boolean | true indicates a waiting node |
| errMsg | string | Error message (present when state is error) |
| executionList | object | Post-node action execution item collection |
|---|---|---|
| requestId | string | Idempotency identifier |
| taskType | string | Specific post-action type. custom_function: execute APL code; send_qixin: CRM notification; updates: post-action updates; send_sms: SMS notification; send_email: email notification; external_message_v2: new version external notification; external_message: legacy version external notification; edit_team_member: add team member; custom_variable_evaluation: variable assignment |
| async | boolean | Whether asynchronous execution is enabled (currently only APL code supports async execution) |
| type | string | Default: approvalflow |
| rowNo | integer | Post-action execution sequence |
| executionState | string | Execution result; success: execution succeeded; error: execution failed |
| actionErrorMsg | string | When executionState is error, this field provides the failure reason |
| userId | string | Executor. Default is system (-10000). If exception occurs, this value shows the specific person who retried or ignored |
| modifyTime | integer | Post-action execution end time |
| createTime | integer | Post-action execution start time |
| sender | string | Email sender (only applicable for email notifications) |
| recipients | object | Selected recipients for SMS/email/CRM notifications, including personnel, departments, user groups, roles, etc. |
| ccRecipients | object | CC recipients (only applicable for email notifications) |
| bccRecipients | object | BCC recipients (only applicable for email notifications) |
| emailAddress | object | Email recipients configured by administrators (only applicable for email notifications) |
| title | string | Title (e.g., used for CRM notifications) |
| content | string | Content (e.g., CRM notification content, SMS content, schedule, sales records, task settings) |
| template | string | Template (e.g., used for email/SMS notifications) |
| updateFieldJson | string | Data structure for field updates |
| customVariables | object | Variable assignment data structure definition |
Return an example
{
"error": false,
"data": [
{
"id": "66f5298c0cf87e114caaa5e2",
"tenantId": "71557",
"appId": "CRM",
"name": "Wait Node 1",
"workflowId": "66f5297b0cf87e114caaa5dd",
"workflowInstanceId": "66f529850cf87e114caaa5e0",
"activityId": "1727342883785",
"activityInstanceId": "4",
"createTime": 1727342988334,
"modifyTime": 1727343031792,
"state": "pass",
"type": "executionTask",
"taskType": "executionTask",
"actionType": null,
"description": "",
"executionList": [
{
"requestId": "66f529b767042a00019402d1",
"tenantId": "71557",
"appId": "CRM",
"taskType": "updates",
"async": null,
"type": "approvalflow",
"rowNo": 0,
"variables": {
"action": "agree"
},
"task": null,
"executionState": "success",
"actionErrorMsg": null,
"activityId": null,
"userId": "-10000",
"modifyTime": 1727343031646,
"createTime": 0,
"sender": null,
"recipients": null,
"ccRecipients": null,
"bccRecipients": null,
"emailAddress": null,
"title": null,
"content": null,
"template": null,
"afterActionDefinitionId": null,
"afterActionMappingId": null,
"actionMapping": null,
"actionParams": null,
"fieldMapping": null,
"updateFieldJson": "[{\"isCalculate\":false,\"key\":\"${object_RlhY0__c.field_Xxb9v__c}\",\"value\":0,\"defaultValue\":\"\"}]",
"updateFieldObject": null,
"triggerParam": null,
"workflowMap": {
"workflowName": "With Wait Node",
"entityId": "object_RlhY0__c",
"type": "approvalflow",
"activityId": "1727342883785",
"sourceWorkflowId": "apprGA9M4NQ562__crmappr",
"appId": "CRM",
"tenantId": "71557",
"applicantId": "1007",
"workflowInstanceId": "66f529850cf87e114caaa5e0",
"workflowId": "66f5297b0cf87e114caaa5dd",
"objectId": "66f5298425255b0007c68360"
},
"customVariables": null,
"useRelated": false,
"relatedObjectId": null,
"relatedEntityId": null
}
],
"entityId": "object_RlhY0__c",
"objectId": "66f5298425255b0007c68360",
"latencyTime": "1.0",
"latencyUnit": "3",
"timeType": null,
"eventExtension": null,
"sourceWorkflowId": null,
"bpmExtension": null,
"taskExecuteState": "",
"executeTime": 1727343048367,
"finishedTime": 1727343031634,
"executor": "-10000",
"delay": true,
"errMsg": null
}
],
"errorMessage": ""
}Code examples
/**
* Two query methods are provided below: query by data ID or instance ID. If a data ID exists in the context, it will be prioritized for querying; otherwise, the instance ID will be used.
*/
Integer pageNumber = 1
Integer pageSize = 20
// Query delayed nodes by data ID
def rst = Fx.approval.findDelayTask((String) context.data._id, null, pageNumber, pageSize)
log.info(rst)
//--------------------------------------------------------------------------------
// Query delayed nodes by instance ID (if an instance ID exists in the function context)
def instanceId = "66f529850cf87e114caaa5e0"
def rst2 = Fx.approval.findDelayTask(null, instanceId, pageNumber, pageSize)
log.info(rst2)17. Get Approval Flow Instance Details (Real-time Query)
Retrieve the details of an approval flow instance in real-time by its process instance ID. The returned results include: trigger time, data change information at triggering, tasks, and task processing outcomes.
Fx.approval.getInstance(<string instanceId>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| instanceId | string | Instance ID | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| error | boolean | Indicates whether an error occurred |
| data | object | Result data |
| errorMessage | string |
| data | object | Result data |
|---|---|---|
| instance | object | Instance information |
| tasks | array[object] | Task information |
| instance | object | Instance information |
|---|---|---|
| instanceId | string | Instance ID |
| instanceName | string | Combination of workflow name and trigger time |
| objectId | string | Data ID of the workflow initiating object |
| triggerType | string | Trigger type |
| applicantId | integer | Initiator ID |
| state | string | Workflow state. Values: pass: approved; reject: rejected; cancel: withdrawn; error: exception |
| createTime | integer | Workflow initiation time |
| endTime | integer | Workflow completion time (empty or 0 if not completed) |
| lastModifyTime | integer | Last modification time of the workflow |
| apiName | string | Primary version number of the workflow |
| cancelTime | integer | Workflow cancellation time (empty or 0 if not cancelled) |
| entityId | string | Workflow initiating object |
| triggerData | object | Trigger data |
| triggerTypeName | string | Trigger type name (Chinese) |
| linkAppName | string | Associated application name (empty for non-interconnected workflows) |
| linkApp | string | Associated application name (empty for non-interconnected workflows) |
| linkAppEnable | boolean | Indicates whether the current workflow is interconnected |
| linkAppType | integer | Interconnection property (can be ignored) |
| superWorkflowInstanceId | string | Parent workflow instance ID (if current workflow is a sub-workflow) |
| triggerData | object | Trigger data |
|---|---|---|
| data | null | Trigger data (not parsed by workflow) |
| callbackData | object | Trigger data (not parsed by workflow) |
| extraData | object | Trigger data (not parsed by workflow) |
| tasks | object | Collection information |
|---|---|---|
| id | string | Task ID |
| type | string | Task type. Values: one_pass or single: single/multi-person approval; all_pass: joint approval |
| state | string | Task state. Values: pass: approved; reject: rejected; cancel: withdrawn; error: exception |
| opinions | array[object] | Approval opinions |
| errMsg | string | Error message returned when task exception occurs (if post-action exception or handler parsing exception) |
| apiName | string | Primary version number of the workflow |
| createTime | integer | Task creation time |
| modifyTime | integer | Last modification time of the task |
| endTime | integer | Task completion time (empty or 0 if not completed, supported after version 930) |
| completePersons | array[integer] | Processed users |
| unCompletePersons | array[integer] | Unprocessed users |
| linkAppName | string | Associated application name (empty for non-interconnected workflows) |
| linkApp | string | Associated application name (empty for non-interconnected workflows) |
| linkAppEnable | boolean | Indicates whether the current workflow is interconnected |
| linkAppType | integer | Interconnection property (can be ignored) |
| taskName | string | Task name |
| opinions | object | Collection information |
|---|---|---|
| userId | integer | Handler |
| actionType | string | Processing result. Values: agree: agreed; reject: rejected; cancel: withdrawn; addTag: pre-tagging; retrieve: retrieve for re-review; auto_pass or auto_agree: auto-approved; tagAfter: post-tagging; skip_task_validate: skip task completion conditions and post-task actions |
| opinion | string | Approval opinion |
| replyTime | integer | Processing time |
Return an example
{
"error": false,
"data": {
"instance": {
"instanceId": "66f50a6f0cf87e114caaa435",
"instanceName": "New 2024-09-26-1850 (2024-09-26 15:17)",
"objectId": "66f50a6e25255b0007b64ca0",
"triggerType": "Create",
"applicantId": 1007,
"state": "in_progress",
"createTime": 1727335023418,
"endTime": 0,
"lastModifyTime": 1727335044456,
"apiName": "apprZVJ6E46RHG__crmappr",
"cancelTime": 0,
"entityId": "object_RlhY0__c",
"triggerData": {
"data": null,
"callbackData": {
"_triggerActionCode": "Add",
"optionInfo": {
"extendsLogInfo": {},
"fromApiName": "object_RlhY0__c",
"fromClone": true,
"fromDraft": false,
"fromId": "66f50a4b25255b0007b5f8fd",
"fromImport": false,
"fromMapping": false,
"fromReferenceCreate": false,
"fromTransform": false,
"skipFuncValidate": false,
"supportValidationResult": true
}
},
"extraData": {
"stage": null,
"detailChange": null,
"useSnapshotForApproval": false,
"newLifeStatus": null,
"detailEntities": null
}
},
"triggerTypeName": "Create",
"linkAppName": null,
"linkApp": null,
"linkAppEnable": false,
"linkAppType": 0,
"superWorkflowInstanceId": null
},
"tasks": [
{
"id": "66f50a6fdeb560342dbd3d0d",
"type": "one_pass",
"state": "pass",
"opinions": [
{
"userId": 1007,
"actionType": "agree",
"opinion": "Approved.",
"replyTime": 1727335044325
}
],
"errMsg": null,
"apiName": "apprZVJ6E46RHG__crmappr",
"createTime": 1727335023423,
"modifyTime": 1727335044325,
"endTime": 1727335044325,
"completePersons": [
1007
],
"unCompletePersons": [],
"linkAppName": null,
"linkApp": null,
"linkAppEnable": false,
"linkAppType": 0,
"taskName": "A"
},
{
"id": "66f50a840cf87e114caaa437",
"type": "one_pass",
"state": "in_progress",
"opinions": [],
"errMsg": null,
"apiName": "apprZVJ6E46RHG__crmappr",
"createTime": 1727335044364,
"modifyTime": 1727335044377,
"endTime": 0,
"completePersons": [],
"unCompletePersons": [
1007
],
"linkAppName": null,
"linkApp": null,
"linkAppEnable": false,
"linkAppType": 0,
"taskName": "B1"
}
]
},
"errorMessage": ""
}Code examples
// This interface is not for real-time query
QueryResult queryResult = Fx.approval.findInstances((String) context.data.object_describe_api_name, ["in_progress"], (String) context.data._id, 10, 0)[1];
if (queryResult != null) {
List dataList = (List) queryResult["dataList"];
def instance = dataList[0];
String instanceId = instance["instanceId"];
// Real-time query for process instance information
Map rst = Fx.approval.getInstance(instanceId).result();
log.info("instanceDetail:" + rst);
} else {
log.info("No data found");
}18. getInstanceProgress Query Process Instance Progress Details
Query Process Instance Progress Details
Fx.approval.getInstanceProgress(<string entityId>, <string objectId>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| entityId | string | Parent entity | Y |
| objectId | string | Data ID | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| error | boolean | Indicates whether an error occurred |
| data | object | Result set |
| errorMessage | string |
| data | object | Result set |
|---|---|---|
| id | string | Process instance ID |
| subState | string | Normal state when process is normal; If state=error: BuildTaskException - Exception when generating next node; CallBackException - Exception in callback object after process completion; CallBackWaiting - Incorrect data state in callback object side, polling retry |
| triggerType | string | Trigger type |
| state | string | Process status |
| objectId | string | Data ID |
| entityId | string | Object that initiated the process |
| applicantId | string | Approval submitter |
| workflowName | string | Process name |
| workflowId | string | Process version ID |
| sourceWorkflowId | string | Process main version ID |
| triggerData | object | Data when workflow is triggered |
| allTasks | array[object] | All tasks |
| triggerData | object | Data when workflow is triggered |
|---|---|---|
| callbackData | object | Trigger data, not parsed or processed by workflow |
| extraData | object | Trigger data, not parsed or processed by workflow |
| allTasks | object | Collection information |
|---|---|---|
| id | string | Task ID |
| taskName | string | Task name |
| type | string | Task type. one_pass or single: single/multi-person approval; all_pass: joint approval |
| state | string | Task status. pass: approved; reject: rejected; cancel: withdrawn; error: exception |
| opinions | array[object] | Approval comments |
| errMsg | string | Returned when task exception occurs, if post-action exception or handler parsing exception |
| linkAppName | string | Associated application name, empty for non-interconnected workflows |
| linkApp | string | Associated application name, empty for non-interconnected workflows |
| linkAppEnable | boolean | Whether current workflow is interconnected |
| linkAppType | integer | Interconnection attribute, can be ignored |
| opinions | object | Description |
|---|---|---|
| userId | string | Handler |
| actionType | string | Processing result. agree: approved; reject: rejected; cancel: withdrawn; addTag: pre-tagging; retrieve: retrieve for re-review; auto_pass or auto_agree: auto-approved; tagAfter: post-tagging; skip_task_validate: skip task completion conditions and post-task actions |
| opinion | string | Approval comment |
| replyTime | integer | Processing time |
Return an example
{
"error": false,
"data": {
"id": "66f50a6f0cf87e114caaa435",
"subState": null,
"triggerType": "Create",
"state": "in_progress",
"objectId": "66f50a6e25255b0007b64ca0",
"entityId": "object_RlhY0__c",
"applicantId": "1007",
"workflowName": "Parallel Rejection and Re-rejection",
"workflowId": "66f50a680cf87e114caaa430",
"sourceWorkflowId": "apprZVJ6E46RHG__crmappr",
"triggerData": {
"data": null,
"callbackData": {
"_triggerActionCode": "Add",
"optionInfo": {
"extendsLogInfo": {},
"fromApiName": "object_RlhY0__c",
"fromClone": true,
"fromDraft": false,
"fromId": "66f50a4b25255b0007b5f8fd",
"fromImport": false,
"fromMapping": false,
"fromReferenceCreate": false,
"fromTransform": false,
"skipFuncValidate": false,
"supportValidationResult": true
}
},
"extraData": {
"stage": null,
"detailChange": null,
"useSnapshotForApproval": false,
"newLifeStatus": null,
"detailEntities": null
}
},
"allTasks": [
{
"id": "66f50a6fdeb560342dbd3d0d",
"taskName": "A",
"type": "one_pass",
"state": "pass",
"opinions": [
{
"userId": "1007",
"actionType": "agree",
"opinion": "Approved.",
"replyTime": 1727335044325
}
],
"errMsg": null,
"linkAppName": null,
"linkApp": null,
"linkAppEnable": false,
"linkAppType": 0
},
{
"id": "66f50a840cf87e114caaa437",
"taskName": "B1",
"type": "one_pass",
"state": "in_progress",
"opinions": [],
"errMsg": null,
"linkAppName": null,
"linkApp": null,
"linkAppEnable": false,
"linkAppType": 0
},
{
"id": "66f50a840cf87e114caaa438",
"taskName": "C1",
"type": "one_pass",
"state": "in_progress",
"opinions": [],
"errMsg": null,
"linkAppName": null,
"linkApp": null,
"linkAppEnable": false,
"linkAppType": 0
}
]
},
"errorMessage": ""
}Code examples
APIResult data = Fx.approval.getInstanceProgress((String) context.data.object_describe_api_name, (String) context.data._id);
log.info(data)19. getTriggerDataByInstanceId Query triggerData related to fixed approval flow and free approval flow instances
Query triggerData related to fixed approval flow and free approval flow instances
Fx.approval.getTriggerDataByInstanceId(<string instanceId>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| instanceId | string | Process instance ID | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| error | boolean | Indicates whether an error occurred |
| data | object | Result data |
| errorMessage | string | Error message returned when an exception occurs |
| data | object | Result data |
|---|---|---|
| extraData | object | Extended information during triggering, not parsed or processed by the workflow |
| data | object | Extended information during triggering, not parsed or processed by the workflow |
| callbackData | object | Extended information during triggering, not parsed or processed by the workflow |
Return an example
{
"error": false,
"data": {
extraData: {
"detailChange": {},
"useSnapshotForApproval": false
},
callbackData: {
"_triggerActionCode": "Add",
"optionInfo": {
"fromMapping": false,
"fromReferenceCreate": false,
"skipFuncValidate": false,
"fromClone": false,
"fromImport": false,
"fromDraft": false,
"supportValidationResult": true,
"fromTransform": false
}
}
},
"errorMessage": ""
}Code examples
Fx.approval.getTriggerDataByInstanceId("618b44e04dfcf72fe16ea6cd").result()