java - 在 Activiti 中,如何检查是否设置了变量?

标签 java workflow activiti

例如,我有一个可以立即启动或延迟启动的工作流(startTime 变量)。

startEvent 之后,我有一个 exclusiveGateway,我在其中检查流程是否应该继续或等到 startTime

<exclusiveGateway id="startGateway" default="startSequenceFlow3"/>
<sequenceFlow id="startSequenceFlow1" sourceRef="startGateway" targetRef="startTimer">
    <conditionExpression xsi:type="tFormalExpression"><![CDATA[${startTime != null}]]></conditionExpression>
</sequenceFlow>

启动工作流传递变量 startTime 工作正常,但不传递 startTime 会引发异常:

Cannot resolve identifier 'startTime'

检查 startTime 是否已设置的最佳方法是什么,因为 startTime != null 不起作用?我宁愿根本不传递 startTime(不是 startTime=null)。

我使用的代码包括变量:

variables.put("startTime", startTime);
ProcessInstance instance = runtimeService.startProcessInstanceByKey(processKey, variables);

或没有:

ProcessInstance instance = runtimeService.startProcessInstanceByKey(processKey, variables);

最佳答案

使用以下表达式:

${execution.getVariable('startTime') != null}

关于java - 在 Activiti 中,如何检查是否设置了变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37547365/

相关文章:

java - 如何获取 URL 查询字符串值

java - 代码工厂方法

java - 如何将 testNG 实例传递到另一个类

asp.net - 您对 Windows Workflow Foundation 有何体验?

mysql - 事件 BPM : Getting 404 error when I changed my h2 database to mysql

java - 如何截断 thymeleaf 中的十进制数字?

git - 如 Adam Dymitruk ("branch per feature"所述,修复工作流程中旧版本中的错误)

c#/.net项目如何保存/组织数据库查询

java - 使用 Spring Boot 在 Activiti 中为 JUnit 测试构建 ApplicationContext 时出现异常

timer - Activiti/Camunda 使用变量更改边界计时器