Add a bpmn property to the ScriptTask


#1

Hii ,

I’m using properties-panel , and i would like to add some properties to my ScriptTask that are defined on the jbpm like this ,

<bpmn2:scriptTask id="ScriptTask_1" name="Script Task 1">
      <bpmn2:incoming>SequenceFlow_5</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_6</bpmn2:outgoing>
      <bpmn2:property id="Property_1" itemSubjectRef="ItemDefinition_62" name="taskVar1">
        <bpmn2:dataState id="DataState_1" name="Data State 1">
          <bpmn2:documentation id="Documentation_2"><![CDATA[heyyyou]]></bpmn2:documentation>
        </bpmn2:dataState>
      </bpmn2:property>
      <bpmn2:humanPerformer id="HumanPerformer_1" name="Human Performer 1">
        <bpmn2:resourceRef>Resource_1</bpmn2:resourceRef>
        <bpmn2:resourceParameterBinding id="ResourceParameterBinding_1">
          <bpmn2:formalExpression id="FormalExpression_2" evaluatesToTypeRef="ItemDefinition_47">ParameterExpressionScript</bpmn2:formalExpression>
        </bpmn2:resourceParameterBinding>
        <bpmn2:resourceParameterBinding id="ResourceParameterBinding_2"/>
        <bpmn2:resourceAssignmentExpression id="ResourceAssignmentExpression_1">
          <bpmn2:formalExpression id="FormalExpression_1" evaluatesToTypeRef="ItemDefinition_62" language="http://www.java.com/java">RessourceScript</bpmn2:formalExpression>
        </bpmn2:resourceAssignmentExpression>
      </bpmn2:humanPerformer>
    </bpmn2:scriptTask>

any proposition ?


Adding a ScriptTask Property
#2

Hi @Marwa_Ajmi,

did you take a look inside some of our bpmn-examples? E.g.


Adding a ScriptTask Property
#3

Hi @Niklas_Kiefer ,

Yes I took a look at those examples , I found that those examples doesn’t answer to my question , all I want to know is the logic to add a property to an existing element with this function

myData = elementHelper.createElement('LoopCondition', { fields: [] }, extensionElements, bpmnFactory);
Thats generates an error

I didn’t know wher to add this representation for example

{
      "name": "LoopCondition",
      "superClass": [ "Element" ],
      "properties": [
        {
          "name": "lastChecked",
          "isAttr": true,
          "type": "String"
        },
        {
          "name": "nextCheck",
          "isAttr": true,
          "type": "String"
        },
        {
          "name": "comments",
          "isMany": true,
          "type": "Comment"
        }
      ]
    }

#4

To add custom properties you will have to implement a metamodel extension, which you seem to initiate with the snippet of JSON. elementHelper.createElement('LoopCondition', { fields: [] }, extensionElements, bpmnFactory); will run inside an error unless you integrate the extension. The example will guide you step by step. Furthermore, the properties-panel example I gave also shows how to add the extension to the properties-panel.

Can you explain for which points do you need more information about the examples? What terms did you not understand?


#5

Good I’m using properties-panel example , I want more information about how to add script tag , in the same example when I click on the ScriptTask element ,
I understand the fact of this function if (is(element, 'bpmn:StartEvent')) {
but I didn’t where the script tag was pushed into ScriptTask tag

Also I have added

  {
      "name": "AnalysisDetails",
      "superClass": [ "Element" ],
      "properties": [
        {
          "name": "lastChecked",
          "isAttr": true,
          "type": "String"
        },
        {
          "name": "nextCheck",
          "isAttr": true,
          "type": "String"
        },
        {
          "name": "comments",
          "isMany": true,
          "type": "Comment"
        }
      ]
},

to the camunda.json file , and finally it was added correctly

Thanks a lot :heart:


#6

Another thing , and I’ll be grateful,
Could you explain to me why the LoopCondition tag and some other tags appears as <bpmn:LoopCondition/>
and not <bpmn:LoopCondition> some thing< bpmn:LoopCondition/>?


#7

Regarding the xml notation, the /> ending simply reveal an empty element with no children. I guess our bpmn reading and writing library follows this notation.

Does this answer your question?