I have this as part of my bpmn:userTask deff:
<bpmn:extensionElements>
<camunda:properties>
<camunda:property name="myProperty" value="0" />
</camunda:properties>
</bpmn:extensionElements>
I have an instanceId and a taskId. How, through the java API, do I get the value?
tair
2
We use something like this:
String taskId = ...;
ProcessEngineServices processEngineServices = ...;
Task task = processEngineServices.getTaskService().createTaskQuery().taskId(taskId).singleResult();
String taskDefinitionKey = task.getTaskDefinitionKey();
String processDefinitionId = task.getProcessDefinitionId();
Optional<String> myPropertyValue = processEngineServices
.getRepositoryService()
.getBpmnModelInstance(processDefinitionId)
.getModelElementsByType(UserTask.class)
.stream()
.filter(userTask -> userTask.getId().equals(taskDefinitionKey))
.map(UserTask::getExtensionElements)
.filter(Objects::nonNull)
.flatMap(e -> e.getElementsQuery().filterByType(CamundaProperties.class).list().stream())
.flatMap(e -> e.getCamundaProperties().stream())
.filter(e -> e.getCamundaName().equals("myProperty"))
.map(CamundaProperty::getCamundaValue)
.findAny();
Would I have to go through the BpmnModelInstance to get something at the process level as well?
I have this:
<bpmn:process id="ny_process" name="My Process" isExecutable="true">
<bpmn:extensionElements>
<camunda:properties>
<camunda:property name="someProperty" value="someValue" />
</camunda:properties>
</bpmn:extensionElements>
I would like to get the “someProperty” value. How would I do that?
tair
4
@mmaceachran yes, just .getModelElementsByType(Process.class)
rim
5
Hello, after starting my process i have a user task i want to get the user task id in order to complete it .i’m codding with java.