I am building some of my UserRequest-Texts with the expression-syntax ( ${abc} )
How can I format numbers to a specific number of decimals + is it possible to use a specific language code for the decimal-sign?
E.g. I want the number 1234.5678 to become “1234,57” (German format)
My current workaround is to use JavaScript, but it would be nice if its possible with an simple expression.
Test BPMN:
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1wmrdz8" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1">
<bpmn:process id="numberFormatTest" name="Number Format Test" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_02oau91</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="Flow_02oau91" sourceRef="StartEvent_1" targetRef="Activity_0lgkgyo" />
<bpmn:endEvent id="Event_0fi3o7x">
<bpmn:incoming>Flow_01xhwco</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_01xhwco" sourceRef="Activity_1pk8ow3" targetRef="Event_0fi3o7x" />
<bpmn:userTask id="Activity_1pk8ow3" name="UserRequest">
<bpmn:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="RequestTextExpression">Your value is ${myNumber}</camunda:inputParameter>
<camunda:inputParameter name="RequestTextScript">
<camunda:script scriptFormat="JavaScript">'Your value is ' + myNumber.toFixed(2).replace('.',',');</camunda:script>
</camunda:inputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>
<bpmn:incoming>Flow_0loskpw</bpmn:incoming>
<bpmn:outgoing>Flow_01xhwco</bpmn:outgoing>
</bpmn:userTask>
<bpmn:sequenceFlow id="Flow_0loskpw" sourceRef="Activity_0lgkgyo" targetRef="Activity_1pk8ow3" />
<bpmn:scriptTask id="Activity_0lgkgyo" name="PrepareValue" scriptFormat="JavaScript" camunda:resultVariable="myNumber">
<bpmn:incoming>Flow_02oau91</bpmn:incoming>
<bpmn:outgoing>Flow_0loskpw</bpmn:outgoing>
<bpmn:script>1234.5678</bpmn:script>
</bpmn:scriptTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="numberFormatTest">
<bpmndi:BPMNEdge id="Flow_02oau91_di" bpmnElement="Flow_02oau91">
<di:waypoint x="208" y="117" />
<di:waypoint x="270" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_01xhwco_di" bpmnElement="Flow_01xhwco">
<di:waypoint x="540" y="117" />
<di:waypoint x="642" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0loskpw_di" bpmnElement="Flow_0loskpw">
<di:waypoint x="370" y="117" />
<di:waypoint x="440" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Event_0fi3o7x_di" bpmnElement="Event_0fi3o7x">
<dc:Bounds x="642" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1grxv0k_di" bpmnElement="Activity_1pk8ow3">
<dc:Bounds x="440" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="172" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1cr3hrv_di" bpmnElement="Activity_0lgkgyo">
<dc:Bounds x="270" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>