我想以嵌入式形式访问过程变量,但无法这样做。我浏览了https://docs.camunda.org/manual/7.8/reference/embedded-forms/javascript/examples/上的文档以及https://github.com/camunda/camunda-bpm-examples/tree/master/usertask/task-form-embedded-serialized-java-object上的示例,我认为我掌握了这些知识,但是即使看起来与1:1一样,以下代码也无法正常工作文档。
也许麻烦是我尝试访问的变量是LinkedHashMap(在Groovy中创建为mVariables = ['something': 'foo']
)
以下代码片段在“ Camunda任务列表”中未显示任何内容。
<form role="form" name="form" xmlns="http://www.w3.org/1999/html">
<script cam-script type="text/form-script">
camForm.on('form-loaded', function() {
camForm.variableManager.fetchVariable('mVariables');
});
camForm.on('variables-fetched', function() {
$scope.mVariables= camForm.variableManager.variable('mVariables').value;
});
</script>
<h1>{{mVariables.something}}</h1>
<p ng-bind="mVariables.something"></p>
<form>
任何人都可以提供一个工作的最小示例来读取过程变量LinkedHashMap吗?
答案 0 :(得分:1)
实际上,LinkedHashMap无法按照我的建议进行传递。它写在此文档站点顶部的灰色框中:https://docs.camunda.org/manual/7.8/reference/embedded-forms/java-objects/
我通过将Map分成多个变量解决了我的问题,这些变量随后可以如下嵌入形式读取:
<form role="form" name="form" xmlns="http://www.w3.org/1999/html">
<script cam-script type="text/form-script">
camForm.on('form-loaded', function() {
camForm.variableManager.fetchVariable('mVariableFoo');
camForm.variableManager.fetchVariable('mVariableBar');
});
camForm.on('variables-fetched', function() {
$scope.mVariableFoo = camForm.variableManager.variable('mVariableFoo').value;
$scope.mVariableBar = camForm.variableManager.variable('mVariableBar').value;
});
</script>
<h1>{{mVariableFoo}}</h1>
<p>{{mVariableBar}}</p>
<form>