Fx.bpm

Fx.bpm: business process related functions

1. Find all business flow instances of the specified object and specified data

Fx.bpm.findInstances(<String objectApiName>, <String state>, <String dataId>, <Integer pageSize>, <Integer pageNumber>)

Parameter Description

| parameter | type | description |
| ------------ | ------------ | ----------------------- ----------------------------------------- |
| objectApiName | String | apiName of the object |
| state | String | String state; Business flow state, supported states: in_progress (in progress), pass (pass), cancel (cancel), error (abnormal) |
| dataId | String | business data Id |
| pageSize | Integer | Amount of data on a page, maximum 100 |
| pageNumber | Integer | current page number |

return type

APIResult

Return value description

The fields related to return approval include: business process id (instanceId) business flow name (workflowName) business flow state (state) sponsor Id (applicantId) start timestamp (start) end timestamp (end)

Java example

APIResult ret = Fx.bpm.findInstances("object_C6kha__c", "in_progress", "600558de3dacbe000167a1d9", 10, 1);
log. info(ret);

Groovy example

def ret = Fx.bpm.findInstances("object_C6kha__c", "in_progress", "600558de3dacbe000167a1d9", 10, 1)
log. info(ret)

2. Find all task nodes of business flow

Fx.bpm.findTaskList(<String instanceId>, <Integer pageSize>, <Integer pageNumber>)

Parameter Description

| parameter | type | description |
| ------------ | ------------ | ----------------------- ----------------------------------------- |
| instanceId | String | business flow instance Id |
| pageSize | Integer | Amount of data on a page, maximum 100 |
| pageNumber | Integer | current page number |

return type

APIResult

Return value description

Task node List, related fields include: Task Id(taskId), task name (taskName) state (state) execution type (executionType), the execution type includes: update (update type node) approve (approval node) externalApplyTask (application node) operation (business operation node) addRelatedObject (add related object ) batchAddRelatedObject (add related objects in batches) batchEditMasterDetailObject (edit slave objects in batches) addMDObject (create slave objects) latency (timed waiting node) node type (taskType), node types include: anyone (single-person processing) all (countersigned approval) required Specify the next node processor: 1 to specify, non-1 to not specify (assignNextTask) application appId (linkApp) application type (linkAppType) node processing opinion (List <Opinion>), Opinion contains the following fields: tenantId node processor's company Id userId userId of node processor actionType processing type opinion processing opinion replyTime processing time

Java example

APIResult ret = Fx.bpm.findTaskList("600655f76cf582000145d366", 10, 1);
log. info(ret);

Groovy example

def ret = Fx.bpm.findTaskList("600655f76cf582000145d366", 10, 1)
log. info(ret)

3. Find the details of a node

Fx.bpm.findTask(<String taskId>)

Parameter Description

| parameter | type | description |
| ------------ | ------------ | ----------------------- ----------------------------------------- |
| taskId | String | taskId |

return type

APIResult

Return value description

name: task name state: state applicantId: initiator entityId: task associated object objectId: task associated data id candidateIds: pending processIds: processed person activityInstanceId: task node number

Java example

APIResult ret = Fx.bpm.findTask("600655f76cf582000145d367");
log. info(ret);

Groovy example

def ret = Fx.bpm.findTask("600655f76cf582000145d367")
log. info(ret)

4. Cancel the process instance

Fx.bpm.cancel(<String instanceId>, <String reason>)

Parameter Description

| parameter | type | description |
| ------------ | ------------ | ----------------------- ----------------------------------------- |
| instanceId | String | business flow instance Id |
| reason | String | Cancellation reason |

return type

APIResult

Java example

APIResult ret = Fx.bpm.cancel("60058b414349d20001b32aef", "No more");
log. info(ret);

Groovy example

def ret = Fx.bpm.cancel("60058b414349d20001b32aef", "No more")
log. info(ret)

5. Operate the approval node (nodes that need to specify the next node task handler are not supported)

Fx.bpm.approval(<String taskId>, <String userId>, <String action>, <String opinion>)

Parameter Description

| parameter | type | description |
| ------------ | ------------ | ----------------------- ----------------------------------------- |
| taskId | String | Approval Node Id |
| userId | String | Approver |
| action | String | Operation type, the supported types are agree (agree), reject (reject) |
| opinion | String | Approval opinion |

return type

APIResult

Return value description

Java example

APIResult ret = Fx.bpm.approval("60058bd24349d20001b32af2", "1000", "agree", "absolutely agree");
log. info(ret);

Groovy example

def ret = Fx.bpm.approval("60058bd24349d20001b32af2", "1000", "agree", "absolutely agree")
log. info(ret)

6. Complete the business node

Fx.bpm.complete(<String taskId>, <String userId>, <String opinion>, <Map map>)

Parameter Description

| parameter | type | description |
| ------------ | ------------ | ----------------------- ----------------------------------------- |
| taskId | String | Service Node Id |
| userId | String | Approver |
| opinion | String | Optional parameter, used together with map to process opinions |
| map | Map | Optional parameter, used together with opinion, other parameters |

return type

APIResult

Return value description

Java example

// Selecting or creating a business flow node of an associated object class can be done automatically through a function, which can be set in the fourth parameter key: "relatedObjectId" -> value: the id of the newly created associated object
Map<String, Object>map = Maps.of("relatedObjectId", "5e16cc13e4817e0001ee1a3e");
APIResult ret = Fx.bpm.complete("60058b414349d20001b32af0", "1000", "pass", map);
log. info(ret);

Groovy example

// Selecting or creating a business flow node of an associated object class can be done automatically through a function, which can be set in the fourth parameter key: "relatedObjectId" -> value: the id of the newly created associated object
Map map = ["relatedObjectId": "5e16cc13e4817e0001ee1a3e"]
def ret = Fx.bpm.complete("60058b414349d20001b32af0", "1000", "pass", map)
log. info(ret)

7. Replace the current node handler

Fx.bpm.changeCandidateIds(<String taskId>, <List candidateIds>, <String opinion>)

Parameter Description

| parameter | type | description |
| ------------ | ------------ | ----------------------- ----------------------------------------- |
| taskId | String | task node id |
| candidateIds | List | Processors to be changed |
| opinion | String | Optional parameter, replace the opinion of the handler |

return type

APIResult

Return value description

Java example

APIResult ret = Fx.bpm.changeCandidateIds("600655f76cf582000145d367", Lists.newArrayList(1000, 1001, 1002));
log. info(ret);

Groovy example

def ret = Fx.bpm.changeCandidateIds("600655f76cf582000145d367", [1000, 1001, 1002])
log. info(ret)

8. Trigger business flow

Fx.bpm.startInstance(<String id>, <String objectId>, <String entityId>)

Parameter Description

| parameter | type | description |
| ------------ | ------------ | ----------------------- ----------------------------------------- |
| id | String | business flow definition id |
| objectId | String | object data Id |
| entityId | String | object apiName |

return type

APIResult

Return value description

String, create the id of the business flow instance

Java example

APIResult ret = Fx.bpm.startInstance("5e9858f5865dbc000155dd87", "e6a338ae8a944cdfb2bae737db1aa12f", "AccountObj");if (ret. isError()) {
    log.info(ret.message());
} else {
    log.info(ret.getData());
}

9. Obtain a list of business flow definitions

Fx.bpm.getDefinitionList(<String entityId>, <int page>, <int pageSize>)

Parameter Description

| parameter | type | description |
| ------------ | ------------ | ----------------------- ----------------------------------------- |
| entityId | String | object ApiName |
| page | int | page number |
| pageSize | int | number of pages |

return type

APIResult

Return value description

Map

Groovy example

// Get the definition according to the 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 according to the process definition name
    i ->if('Definition obtained by the function' == i['workflowName']){
      //trigger business flow
      Fx.bpm.startInstance(i['id'] as String, '62c39d5d71f9010001ae0ea9', 'FundReturnBackObj')
    }
  }
}

10. The business flow waits for the node to execute immediately

Fx.bpm.delayTaskImmediatelyExecute(<String taskId>)

Parameter Description

| parameter | type | description |
| ------------ | ------------ | ----------------------- ----------------------------------------- |
| taskId | String | waiting node id |

return type

APIResult

Return value description

Map

Java example

APIResult res = Fx.bpm.delayTaskImmediatelyExecute("62f320a7c6fa24292be4f830");
if(res.isError() || res.message() != ""){
  log. info(res. message())
}else{
  log.info("The automatic node of the business flow is executed successfully immediately")
}

11. Re-parsing task handlers

Fx.bpm.refreshHandler(<String taskId>)

Parameter Description

| parameter | type | description |
| ------------ | ------------ | ----------------------- ----------------------------------------- |
| taskId| String | task id |

return type

APIResult

Return value description

Map

Java example

String taskId = "6343e4d780f4841c79cbcae0";
APIResult ret = = Fx.bpm.refreshHandler(taskId);
if (ret. isError()) {
    log.info(ret.message());
} else {
    log.info(ret.getData());
}

Groovy example

def taskId = "6343e4d780f4841c79cbcae0"
def res = Fx.bpm.refreshHandler(taskId)
log. info(res)

2022-11-23
0 0