How to add dynamic values to field injections list with custom trigger?

I have two questions here

  1. Is it possible to add dynamic lists values to field injection list input ?
  2. Can I create a trigger for this so this can be initiated from any other input selection say a class selection will populate all fields

I was just looking into FieldInjection.js whether that can be extented for the same

Can someone please provide a hint or direction for this ?

Thanks.

For anyone interested in the answer, I was able to achieve the above goal by changing the set function of the Java Class select input as

var CAMUNDA_FIELD_EXTENSION_ELEMENT = 'camunda:Field';

function getExtensionFields(bo) {
      return bo && extensionElementsHelper.getExtensionElements(bo, CAMUNDA_FIELD_EXTENSION_ELEMENT) || [];
}

set: function(element, values, node) {
      var bo = getBusinessObject(element);
      var type = getImplementationType(element);
      var attr = getAttribute(type);
      var prop = {}
      var commands = [];
      prop[attr] = values.delegate || '';
      var extensionElements = getExtensionFields(bo);
      //remove any extension elements existing before
      extensionElements.forEach(function(ele){
        commands.push(extensionElementsHelper.removeEntry(getBusinessObject(element), element, ele));
      });
      if(prop[attr] !== ""){
        var extensionElements = elementHelper.createElement('bpmn:ExtensionElements', { values: [] }, bo, bpmnFactory);
        commands.push(cmdHelper.updateBusinessObject(element, bo, { extensionElements: extensionElements }));
        var arrProperties = ["private org.camunda.bpm.engine.delegate.Expression com.cfe.extensions.SampleJavaDelegate.varOne","private org.camunda.bpm.engine.delegate.Expression com.cfe.extensions.SampleJavaDelegate.varTwo"]
         
        var newFieldElem = "";
        arrProperties.forEach(function(prop){
          var eachProp = {
            name:"",
            string:"",
            expression:""
          }
          var type = prop.split(" ")[1].split(".").reverse()[0];
          var val = prop.split(" ")[2].split(".").reverse()[0];
          eachProp.name = val;
          if( type == "String"){
            eachProp.string = "${" + val  +" }"
          }else if( type == "Expression"){
            eachProp.expression = "${" + val  +" }"
          }

          newFieldElem = elementHelper.createElement(CAMUNDA_FIELD_EXTENSION_ELEMENT, eachProp, extensionElements, bpmnFactory);
          commands.push(cmdHelper.addElementsTolist(element, extensionElements, 'values', [ newFieldElem ]));
        });
      }
      commands.push(cmdHelper.updateBusinessObject(element, bo, prop));
      return commands;
    } 

Cheers !.

2 Likes