English
Fx.stage
About 1831 wordsAbout 6 min
2026-01-09
1. trigger phase thruster
Trigger Phase Thruster
Fx.stage.trigger(<String entityId>, <String objectId>, <String userId>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| entityId | String | API name of the initiating object | Y |
| objectId | String | Data ID of the initiating object | Y |
| userId | String | ID of the stage promoter's initiator | Y |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| workflowInstanceId | string | Workflow instance ID |
Return an example
{
"workflowInstanceId": "66f50d510cf87e114caaa447"
}Code examples
def(Boolean error, Map data, String errorMessage) = Fx.stage.trigger("object_qep6N__c", "617f9b7340beec0001b9b14e", "1000")
if (error) {
log.info(errorMessage)
} else{
log.info(data)
}2. matchDef Matches the stage propellers that can be triggered (non-Opportunity 2.0)
Match the stage triggers that can be activated (non-Opportunity 2.0)
Fx.stage.matchDef(<String entityId>, <String objectId>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| entityId | String | API name of the initiating object | Y |
| objectId | String | Data ID of the initiating object | Y |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| stagePropellerName | string | Stage propeller definition name |
| isCurrentDef | boolean | Whether the current instance is the active definition |
| sourceWorkflowId | string | Matched stage propeller definition ID |
| hasInstance | boolean | Whether workflow instances exist |
Return an example
{
"sourceWorkflowId": "66f3f79122907b00016f0849",
"isCurrentDef": true,
"hasInstance": true,
"stagePropellerName": "Optional Completion Test"
}Code examples
def api_name = context.data.object_describe_api_name as String
def object_id = context.data._id as String
log.info(api_name + "," + object_id)
def match_result = Fx.stage.matchDef(api_name, object_id, "1000")
log.info(match_result)3. change Switch stage propellant (Not applicable for Opportunity 2.0. This function cannot be used to manipulate Opportunity 2.0 objects)
Switch Stage Propeller (Not applicable for Opportunity 2.0. This function cannot be used to manipulate Opportunity 2.0 objects.)
Fx.stage.change(<String entityId>, <String objectId>, <String sourceWorkflowId>, <String stageId>, <String userId>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| entityId | String | Object API Name | Y |
| objectId | String | Data ID | Y |
| sourceWorkflowId | String | Definition ID of the stage promoter obtained through pre-matching, refer to Fx.stage.matchDef | Y |
| stageId | String | Initial stage ID | Y |
| userId | String | User ID | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| isError | Boolean | Whether an error occurred |
| data | Map | Returned data |
| message | String | Message |
Return an example
{
"isError": false,
"data": {},
"message": ""
}Code examples
// Non-Opportunity 2.0 Object Stage Transition Promoter
def match_result = Fx.stage.change("object_qep6N__c", "66f61a1f3005aa0001d14b54", "61a87f17bb3d4700017f5a78", "1", "1000")
log.info(match_result)
// Note: For Opportunity 2.0 objects, it is recommended to use Fx.object.update to modify the "Sales Process" field for stage transition promotion.
// The following code is for reference only:
String sourceWorkflowId = "640ac64fd7d00c767d0d9641" // sourceWorkflowId of the target stage transition promoter
String stageId="1" // Initial stage ID after stage transition
String objectAPIName = "NewOpportunityObj"
String objectId = context.objectIds[0]
Map updateData = [
"sales_process_id":sourceWorkflowId,
"sales_stage":stageId
]
def (Boolean error, Map data, String errorMessage) = Fx.object.update( objectAPIName, objectId, updateData, false, false)
if (error) {
log.info("error:" + errorMessage )
}
log.info(data)Notice
- Only supports non-Opportunity 2.0 objects. The Opportunity 2.0 objects are not allowed to use this function for stage promotion.
4. changeTaskHandler Change Handler
Update and complete tasks
Fx.stage.changeTaskHandler(<String taskId>, <List candidateIds>, <String userId>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| taskId | String | Task ID | Y |
| candidateIds | List | Collection of handler IDs to be replaced | Y |
| userId | String | User ID | 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
def rst = Fx.stage.changeTaskHandler("6343ff9e80f4841c79cbcb5c", ["1000"], "1106")
log.info(rst)5. completeCreateAndRelatedTask Complete selected associated tasks
Complete the selected associated task
Fx.stage.completeCreateAndRelatedTask(<String taskId>, <String entityId>, <String objectId>, <String ignoreNoBlockValidate>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| taskId | String | Task ID | Y |
| entityId | String | API name of the created object | -- |
| objectId | String | Data ID of the created object. Multiple IDs should be separated by vertical bars | -- |
| ignoreNoBlockValidate | String | Ignore non-blocking exceptions. When completing the task, continue execution despite non-blocking exceptions | -- |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| currentStageTaskAllCompleted | boolean | Whether all tasks in the current stage are completed |
Return an example
{
"currentStageTaskAllCompleted": false
}Code examples
def rst = Fx.stage.completeCreateAndRelatedTask("6343ff9e80f4841c79cbcb5c", "object_qep6N__c", "617f9b7340beec0001b9b14e|617f9b7340beec0001b9b14f", "1106")
log.info(rst)6. updateAndCompleteTask Update and Complete Task
Update and complete the task
Fx.stage.updateAndCompleteTask(<String taskId>, <Map data>, <String userId>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| taskId | String | Task ID | Y |
| data | Map | Data information to be updated | Y |
| userId | String | User ID | 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": true,
"data": null,
"message": "Task does not exist, please verify"
}Code examples
def data = ["name": "value"]
def rst = Fx.stage.updateAndCompleteTask("6343ff9e80f4841c79cbcb5c", data, "1001")
log.info(rst)7. reactive reactivation
Reactivate
Fx.stage.reactive(<String workflowInstanceId>, <String activeStageId>, <Map data>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| workflowInstanceId | String | Workflow instance ID | Y |
| activeStageId | String | Target stage ID for jumping | Y |
| data | Map | Reactivated form data | -- |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| success | boolean | Whether activation succeeded |
| ruleMessage | object | Reactivation blocking exception message |
| skipInNonBlockMessage | string | Reactivation non-blocking exception message |
| jobId | string | When stage transition is asynchronous, use this value to track transition status |
| versionCheckBlocked | boolean | Whether edit conflicts occurred during data update |
| dataConflicts | object | Content of data conflicts |
Return an example
{
"success": true
}Code examples
// Reactivate function demo
// Instance ID
def workflowInstanceId="62c3da4e0d9f997b27dfd90e"
// Target stage to reactivate
def activeStageId="47u3S02Gz"
// Reactivation form data
Map data= ["field_0mvhC__c": "90"]
def userId= "1000"
def(boolean error, Map result, String message) = Fx.stage.reactive(workflowInstanceId, activeStageId, data, userId)
if (error) {
log.info("error :" + message)
} else {
log.info(result)
}8. reactiveValidate reactivate validation
Reactivate Verification
Fx.stage.reactiveValidate(<String workflowInstanceId>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| workflowInstanceId | String | The instance ID to be activated | Y |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| success | boolean | Whether the validation passed |
| stageFieldApiName | string | API name of the stage field |
| ruleMessage | Map | Blocking exception message for reactivation validation |
| reactiveTaskData | object | Data of the reactivation form |
| canMoveToStageIds | List[string] | Target stage IDs available for activation |
| skipInNonBlockMessage | string | Non-blocking exception message for reactivation validation |
Return an example
{
"success": true,
"canMoveToStageIds": [
"AaSah2ef5",
"xr1ER6AL8"
],
"stageFieldApiName": "field_2xqgf__c"
}Code examples
// Demo for reactivation validation function interface
// Instance ID
def workflowInstanceId= "62c3da4e0d9f997b27dfd90e"
def userId = context.userId
def(boolean error, Map result, String message) = Fx.stage.reactiveValidate(workflowInstanceId, userId)
if (error) {
log.info("error: " + message)
} else {
log.info(result)
}9. getInstanceInfo Retrieve phase instance information of the object (form layout distribution, description and data)
Retrieve the phase instance information of an object (form layout distribution, description, and data)
Fx.stage.getInstanceInfo(<String entityId>, <String objectId>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| entityId | String | Entity API Name | Y |
| objectId | String | Data ID | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| isError | Boolean | Whether an error occurred |
| data | Map | Returned data |
| message | String | Message |
Return an example
{
"isError": false,
"data": {},
"message": ""
}Code examples
def objectId = "63f6d5b94315da0001585821"; //Data ID
def entityId = "object_8F03i__c"; //Object API Name
def (Boolean error, Map data, String message) = Fx.stage.getInstanceInfo(entityId, objectId);
if (error) {
log.info("error:" + message)
}
log.info(data)10. regenerateHandler Re-parse task assignee
Reparse Task Handler
Fx.stage.regenerateHandler(<String stageTaskId>, <String opinion>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| stageTaskId | String | Stage task ID | Y |
| opinion | String | Opinion | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| isError | Boolean | Error flag |
| data | Map | Response data |
| message | String | Message |
Return an example
{
"isError": true,
"data": {},
"message": "Fx.stage.regenerateHandler error. status code:400"
}Code examples
def stageTaskId = "63f6d7a3363f0627220ac287"; // Stage ID
def opinion = "Auto-refresh task handler due to data owner change"; // Comment
def (Boolean error, Map data, String message) = Fx.stage.regenerateHandler(stageTaskId, opinion);
if (error) {
log.info("error:" + message)
}
log.info(data)11. completeTask Complete Task
Complete the task
Fx.stage.completeTask(<String taskId>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| taskId | String | Task ID | Y |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| currentStageTaskAllCompleted | boolean | Whether all tasks in the current stage are completed |
| blockMessage | string | Function blocking exception message |
| nonBlockMessage | string | Function non-blocking exception message |
| ruleMessage | object | Validation rule exception message |
Return an example
{
"currentStageTaskAllCompleted": false
}Code examples
// Note: Use Fx.stage.updateAndCompleteTask to complete editing tasks;
// Use Fx.stage.completeCreateAndRelatedTask to complete object creation and association tasks
def taskId = "67e0feea650b3007ce0ee6b7"
def userId = "1002"
// blockMessage: function blocking exception message, nonBlockMessage: function non-blocking exception message, ruleMessage: validation rule exception message
def message = Fx.stage.completeTask(taskId, userId)[1]
.with { data ->
data["blockMessage"] ?: data["nonBlockMessage"] ?: data["ruleMessage"]
}
// Log recording (explicitly indicating scenarios when no message is found)
if (message) {
log.error("Exception message: ")
} else {
log.error("No exception message found")
}12. getInstanceTasks Retrieve all tasks in the phase driver instance based on entityId and objectId
Retrieve all tasks in the stage thruster instance based on entityId and objectId
Fx.stage.getInstanceTasks(<String entityId>, <String objectId>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| entityId | String | Object apiName | Y |
| objectId | String | Data ID | Y |
Return Parameters
| Parameter Name | APIResult | Description |
|---|---|---|
| tasks | List[object] | All tasks in the phase accelerator instance |
| tasks | object | Description |
|---|---|---|
| name | string | Task name |
| taskId | string | Task ID |
| executionType | string | Task type: update - edit task, addRelatedObject - select or create, batchUpdateDetailObj - batch edit, empty - empty task, operateObject - object operation |
| state | string | Task status |
Return an example
{
"tasks": [
{
"executionType": "update",
"name": "Edit",
"state": "pass",
"taskId": "66f50d510cf87e114caaa44c"
}
]
}Code examples
def entityId = "NewOpportunityObj" // Object API Name
def objectId = context.data._id as String // Data ID
def ret = Fx.stage.getInstanceTasks(entityId, objectId)
log.info(ret)13. getBySourceWorkflowId Retrieve stage accelerator definition by sourceWorkflowId
Retrieve stage promoter definitions by sourceWorkflowId
Fx.stage.getBySourceWorkflowId(<String sourceWorkflowId>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| sourceWorkflowId | String | Stage promoter ApiName (unique identifier of the stage promoter) | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| isError | Boolean | Error flag |
| data | Map | Response data |
| message | String | Message |
Return an example
{
"isError": false,
"data": {
"modifier": "1002",
"description": "",
"rule": {
"deleted": false,
"conditionPattern": "",
"workflowSrcId": "66f61a1f3005aa0001d14b54",
"entityId": "object_scheduled_object__c",
"ruleId": "66f61a1f0cf87e114caaa717"
}
},
"message": ""
}Code examples
def(boolean error, Map data, String message) = Fx.stage.getBySourceWorkflowId("667bc6b9ed7d04000171daaf")
if (error) {
log.info("error: " + message)
} else {
log.info(data)
}Notice
- This function is used to retrieve detailed information of a phase thruster based on its sourceWorkflowId. Due to the lengthy response data, only a portion of the output parameters is displayed in the example. For the complete output structure, please refer to the log printouts.
14. cancel Terminates the stage promoter instance on the specified object's data record by API name and data ID (only supports instances of non-Opportunity 2.0 objects)
Terminate the stage pusher instance on an object based on its apiName and data ID (only supports instances of non-opportunity 2.0 objects)
Fx.stage.cancel(<String entityId>, <String objectId>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| entityId | String | Object API Name | Y |
| objectId | String | Data ID | 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": true,
"data": {},
"message": "No stage process instance exists"
}Code examples
def entityId = "object_8F03i__c"
def objectId = context.data._id
def(Boolean error, Map data, String message) = Fx.stage.cancel(entityId, objectId)
if (error) {
log.info("error:" + message)
}
log.info(data)Notice
- This function only supports instances of non-opportunity 2.0 objects
