当前位置:网站首页>Activiti7 task service - process variables (setvariable and setvariablelocal)

Activiti7 task service - process variables (setvariable and setvariablelocal)

2022-07-04 04:03:00 keep-go-on

The role of process variables

The role of task variables mainly consists of the following roles .

  • Task undertaker parameters . Task start or midway through the variable to specify the task acceptor .
  • Gateway condition variable . Provide data for the gateway when the task starts or midway .
  • Task extension attribute . Provide extended attributes for tasks , Available for retrieval .
  • Dynamically modify the attributes of the process .

Task services provide setVariableLocal and setVariable Two methods provide methods to set variables for processes and tasks . The runtime process variable table is act_ru_variable.

Task service setVariable Method

How to use it is as follows :

taskService.setVariable(taskId,key,value);

Database result :
 Insert picture description here

Use setVariable Method to set process variables , The granularity associated with variables is the process instance ID(PROC_INST_ID_) Not the task ID, Process variables belong to the global .

Task service setVariableLocal Method

How to use it is as follows :

taskService.setVariableLocal(taskId,key,value);

The database results are as follows :

 Insert picture description here

Use setVariableLocal The variable granularity set by the method is directly related to the task ID, Variables belong to tasks ( A task is a process node ) Of .

The difference between queries

Query global variables

 taskQuery.taskVariableValueEquals("test_var","099098087");

Query global variables ( Use setVariable Method to set process variables ), Query results :

{
    
    {
    
    "code": 10000,
    "msg": " success ",
    "status": true,
    "data": {
    
        "records": [],
        "total": 0,
        "size": 10,
        "current": 1,
        "orders": [],
        "optimizeCountSql": true,
        "searchCount": true,
        "pages": 0
    }
}

Because the global variable is not associated with the task task , Therefore, the task cannot be queried .

Query task variables

 taskQuery.taskVariableValueEquals("test_varrrrr","099098087");

The query results are as follows :

{
    
    "code": 10000,
    "msg": " success ",
    "status": true,
    "data": {
    
        "records": [
            {
    
                "taskId": "ffd43354-8bde-11ec-a6d1-b42e996769a4",
                "taskName": " Approved by ",
                "processInstanceId": "ffc1bcb7-8bde-11ec-a6d1-b42e996769a4",
                "processDefinitionId": "635cc307-8a6b-11ec-9c5b-b42e996769a4",
                "createTime": "2022-02-12T08:37:23.272+00:00",
                "taskDefinitionKey": "node_92754730680",
                "assignee": "user_C"
            }
        ],
        "total": 1,
        "size": 10,
        "current": 1,
        "orders": [],
        "optimizeCountSql": true,
        "searchCount": true,
        "pages": 1
    }
}

According to the screenshot above, we can see , The task queried is the task associated with the task .

原网站

版权声明
本文为[keep-go-on]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202141714536507.html