cancel
Showing results for 
Search instead for 
Did you mean: 

Task listener , In seconda section , adding variable in Expression for class does not work

jain_shweta5
Champ in-the-making
Champ in-the-making
1. Click on Task listener of User task.
2. Provide the class for Event create.
3. Now on second section , provide variable in Name and String Value, which works fine and able to get recognised by activiti-explorer and appeared in act_ru_variable, but If instead of String value , provide the value in Expression with ${var} , it does not get appeared in act_ru_variable.
2 REPLIES 2

frederikherema1
Star Contributor
Star Contributor
Do you see an exception? Can you share the relevant section of the generated BPMN-xml?

jain_shweta5
Champ in-the-making
Champ in-the-making
Thanks for you reply!
In BaseBpmnJsonConverter.java  method convertJsonToListeners
added following code resolves the problem

  if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_TASK_LISTENER_FIELDS, itemNode))) {
             JsonNode fielsdNode = itemNode.get(PROPERTY_TASK_LISTENER_FIELDS);
             try {
              fielsdNode = objectMapper.readTree(fielsdNode.asText());
             } catch (JsonProcessingException e) {
              e.printStackTrace();
             } catch (IOException e) {
              e.printStackTrace();
             }
             JsonNode fieldsArrayNode = fielsdNode.get(EDITOR_PROPERTIES_GENERAL_ITEMS);
             if (fieldsArrayNode != null) {
              List<FieldExtension> fieldExtensions = new ArrayList<FieldExtension>();
              for (JsonNode fieldItemNode : fieldsArrayNode) {
               FieldExtension fieldExtension = new FieldExtension();
               if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_TASK_LISTENER_FIELD_NAME,
                 fieldItemNode))) {
                fieldExtension.setFieldName(getValueAsString(PROPERTY_TASK_LISTENER_FIELD_NAME, fieldItemNode));
               }
               if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_TASK_LISTENER_FIELD_VALUE,
                 fieldItemNode))) {
                fieldExtension.setStringValue(getValueAsString(PROPERTY_TASK_LISTENER_FIELD_VALUE, fieldItemNode));
               }
               if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_TASK_LISTENER_FIELD_EXPRESSION,
                 fieldItemNode))) {
                fieldExtension.setExpression(getValueAsString(PROPERTY_TASK_LISTENER_FIELD_EXPRESSION, fieldItemNode));
               }
               fieldExtensions.add(fieldExtension);
              }
              listener.setFieldExtensions(fieldExtensions);
             }
            } 

It would be good , if you can provide this code in next release. Thanks