AnsweredAssumed Answered

execution.setVariable type

Question asked by fussel on Mar 11, 2015
Latest reply on Mar 13, 2015 by fussel
Hi everyone,

I encountered something a little weird. In my process I'm letting a Script Task calculate a value for me (from two form properties that have the type long) , which I set as variable and want to display in the following User Task. According to jUnit everything works fine.
But: when I'm deploying my process ind start it in the Explorer the calculated value is suddenly a float, the Explorer obviously isn't happy with that, because it's expecting a long.
Why is that and is there a way to set the type when I do that execution.setVariable thing?

Here's the relevant part of my process definition:

<startEvent id="startevent1" name="Start" activiti:initiator="initiator">
        <activiti:formProperty id="anzahlAntrag" name="Der wie vielte Urlaubsantrag ist dies im betreffenden Jahr?" type="long" required="true"></activiti:formProperty>
        <activiti:formProperty id="anzahlTage" name="Anzahl der gewünschten Urlaubstage" type="long" required="true"></activiti:formProperty>
        <activiti:formProperty id="zeitraumVom" name="Gewünschter Urlaubsanfang" type="date" datePattern="dd-MM-yyyy" required="true"></activiti:formProperty>
        <activiti:formProperty id="zeitraumBis" name="Gewünschtes Urlaubsende" type="date" datePattern="dd-MM-yyyy" required="true"></activiti:formProperty>
        <activiti:formProperty id="resturlaub" name="Resturlaub (den aktuellen Antrag nicht mit einbezogen)" type="long" required="true"></activiti:formProperty>
<sequenceFlow id="flow15" sourceRef="startevent1" targetRef="scripttask1"></sequenceFlow>
<scriptTask id="scripttask1" name="Ermittlung des Resturlaubs" scriptFormat="javascript" activiti:autoStoreVariables="false">
         var restNeu = resturlaub - anzahlTage;
         execution.setVariable("restNeu", restNeu);
         print('Neuer Resturlaub: '+restNeu);
<sequenceFlow id="flow20" sourceRef="scripttask1" targetRef="usertask1"></sequenceFlow>
    <userTask id="usertask1" name="Gegenprüfung des Antrags" activiti:candidateGroups="teamAssistance">
        <activiti:formProperty id="urlaubsantragsnummer" name="Urlaubsantragsnummer" type="long" expression="${anzahlAntrag}" writable="false"></activiti:formProperty>
        <activiti:formProperty id="resturlaubNeu" name="Resturlaub nach Abzug der gewünschten Tage" type="string" expression="${restNeu}" writable="false"></activiti:formProperty>

Thanks and best regards