cancel
Showing results for 
Search instead for 
Did you mean: 

Set value for a variable in form

rajee434
Champ in-the-making
Champ in-the-making
Hi ,

I have a variable named "Status" with value "applied" in start event form.
Now i want to set the value for that variable as "Progressed" in my next event.
How to set the value?
What type of task should i use for this?

Is it possible with script type task? If so how?

Thanks
Rj
10 REPLIES 10

jbarrez
Star Contributor
Star Contributor
In the script task, just do  'myVar = 'test'' and it should work.

rajee434
Champ in-the-making
Champ in-the-making
Hi,

I have a variable named "status" in a from.
Now on next task(ScriptTask) i want to assign a value to that variable.
How to do it?
I tried like
<scriptTask completionQuantity="1" id="sid-64A7B10A-D832-4DC7-BD79-16A5BF97A624" isForCompensation="false" name="Application status &quot;onhold&quot;" scriptFormat="groovy" activiti:resultVariable="status" startQuantity="1">
         <extensionElements>
            <signavio:signavioMetaData metaKey="bgcolor" metaValue="#ffffcc"/>
         </extensionElements>
         <incoming>sid-8D20906C-5740-4007-B82B-C27F4DD3BEC0</incoming>
         <script>
def scriptVar = "applied"
    execution.setVariable("status", scriptVar)
         </script>
</scriptTask>

But my variable is not updated.
Why is it so?
How should i update an existing variable?

Thanks,
rajee

frederikherema1
Star Contributor
Star Contributor
The code you show should work, afaik. Do you get an error or does the scripttask run successfully without updating the variable?

rajee434
Champ in-the-making
Champ in-the-making
Hi ,

I didnt get any errors.
The script ran successfully without any update to the variable.
The next task i send mail using Email task.
In that i used the variable.
But in mail the variable was not present.
Neither the previous or updated value was present.
What am i missing?

Thanks
Rajee

frederikherema1
Star Contributor
Star Contributor
Can you show your full process BPMN?

rajee434
Champ in-the-making
Champ in-the-making
Hi ,

I have attached my full process bpm with this. My problem is with status.
The email layout is for testing. I also checked by assigning the status variable as a field in my next user task form. But stil the value is empty.
Check with script task id="sid-82D76613-81AC-4A7A-BF0D-FDD15CE08F00" and user task id="sid-08848121-EB04-4B47-8F77-B4AD173027BE"

Thanks,
Rajee

rajee434
Champ in-the-making
Champ in-the-making
Hi,
FYI:
This is my full process bpm
<process id="sid-55fe1097-311b-4f3c-a1e7-b998ce0c1d20" isExecutable="false" name="ApplyForTrademark">
      <startEvent id="sid-72D7810B-1C98-47B9-A42F-54525D9D75F7" name="Application for&#10;trademark" activiti:formKey="SampleTDForm/sample.form" activiti:initiator="initiator" >
         <extensionElements>
            <signavio:signavioMetaData metaKey="bgcolor" metaValue="#ffffff"/>
         </extensionElements>
         <outgoing>sid-BC51B542-1F6E-4F76-A504-5373BDE20C3E</outgoing>
         <outgoing>sid-36728B93-2E8A-4077-859C-CC5A1DE98B3C</outgoing>
      </startEvent>

      <scriptTask completionQuantity="1" id="sid-82D76613-81AC-4A7A-BF0D-FDD15CE08F00" isForCompensation="false" name="Application status &quot;Applied&quot;" scriptFormat="groovy"   activiti:resultVariable="status" startQuantity="1">
         <extensionElements>
            <signavio:signavioMetaData metaKey="bgcolor" metaValue="#ffffcc"/>
         </extensionElements>
         <incoming>sid-36728B93-2E8A-4077-859C-CC5A1DE98B3C</incoming>
         <outgoing>sid-757CB818-1947-4AEF-B5A5-7932A083B0ED</outgoing>
<script>
def scriptVar = "applied"
    execution.setVariable("status", scriptVar)
         </script>
      </scriptTask>
      <parallelGateway gatewayDirection="Diverging" id="sid-483CA4AE-D7BD-4DFE-A0B8-6ED892C7B054" name="">
         <extensionElements>
            <signavio:signavioMetaData metaKey="bgcolor" metaValue="#ffffff"/>
         </extensionElements>
         <incoming>sid-757CB818-1947-4AEF-B5A5-7932A083B0ED</incoming>
         <outgoing>sid-685A2BA3-278A-4648-B234-6D382C707660</outgoing>
         <outgoing>sid-72438261-369F-497F-8A2A-32FC8876C0CC</outgoing>
         <outgoing>sid-549A038B-B1FD-4F49-92C1-4191596B285B</outgoing>
      </parallelGateway>
      <userTask completionQuantity="1" id="sid-08848121-EB04-4B47-8F77-B4AD173027BE" activiti:candidateGroups="management" activiti:formKey="SampleTDForm/samples.form"
                    implementation="webService" isForCompensation="false" name="Process the application" startQuantity="1">
         <extensionElements>
            <signavio:signavioMetaData metaKey="bgcolor" metaValue="#ffffcc"/>
         </extensionElements>
         <incoming>sid-685A2BA3-278A-4648-B234-6D382C707660</incoming>
         <outgoing>sid-681CE2A6-A372-4D63-9227-2AB86BB37CDC</outgoing>
      </userTask>
      <userTask completionQuantity="1" id="sid-39CA73FE-654B-4EBE-86EE-1465DB6A762C" activiti:candidateGroups="management"
activiti:formKey="SampleTDForm/NeedInfo.form" implementation="webService" isForCompensation="false" name="Need further details?" startQuantity="1">
         <extensionElements>
            <signavio:signavioMetaData metaKey="bgcolor" metaValue="#ffffcc"/>
         </extensionElements>
         <incoming>sid-681CE2A6-A372-4D63-9227-2AB86BB37CDC</incoming>
         <outgoing>sid-BE833B5F-8B2C-45E2-95F5-805CF31AC4B2</outgoing>
      </userTask>
      <exclusiveGateway gatewayDirection="Diverging" id="sid-2636D6F5-7A35-42A1-ADE7-FE35D90AD1E2" name="">
         <extensionElements>
            <signavio:signavioMetaData metaKey="bgcolor" metaValue="#ffffff"/>
         </extensionElements>
         <incoming>sid-BE833B5F-8B2C-45E2-95F5-805CF31AC4B2</incoming>
         <outgoing>sid-D2EDA943-BC3C-4C6F-840C-F411A9721875</outgoing>
         <outgoing>sid-88ADB815-5985-4661-92C8-4B685E948A2F</outgoing>
      </exclusiveGateway>
<sequenceFlow id="flow8" sourceRef="sid-2636D6F5-7A35-42A1-ADE7-FE35D90AD1E2" targetRef="sid-13F6035B-B0E1-436D-92F2-C5F117B27769">
           <conditionExpression>${notEnoughInformation}</conditionExpression>
         </sequenceFlow>
         <sequenceFlow id="flow9" sourceRef="sid-2636D6F5-7A35-42A1-ADE7-FE35D90AD1E2" targetRef="sid-E8837476-A72C-4DF8-BDB8-1ECA86AE6C00">
           <conditionExpression>${!notEnoughInformation}</conditionExpression>
         </sequenceFlow>

      <parallelGateway gatewayDirection="Diverging" id="sid-13F6035B-B0E1-436D-92F2-C5F117B27769" name="">
         <extensionElements>
            <signavio:signavioMetaData metaKey="bgcolor" metaValue="#ffffff"/>
         </extensionElements>
         <incoming>sid-D2EDA943-BC3C-4C6F-840C-F411A9721875</incoming>
         <outgoing>sid-15C370A0-B001-4529-A2E7-E68B60EB94FD</outgoing>
         <outgoing>sid-8D20906C-5740-4007-B82B-C27F4DD3BEC0</outgoing>
      </parallelGateway>
      <serviceTask completionQuantity="1" id="sid-E8837476-A72C-4DF8-BDB8-1ECA86AE6C00" activiti:type="mail" implementation="webService" isForCompensation="false" name="Email to applicant " startQuantity="1">
         <extensionElements>
            <signavio:signavioMetaData metaKey="bgcolor" metaValue="#ffffcc"/>
<activiti:field name="from" stringValue="rajee_gaekwad@yahoo.co.in" />
    <activiti:field name="to" expression="rajee_gaekwad@yahoo.co.in" />
    <activiti:field name="subject" expression="Your order  has been shipped" />
    <activiti:field name="html">
      <activiti:expression>
        <![CDATA[
          <html>
            <body>
              Hello Miss rajee,<br/><br/>
                
              As of your order has been <b>processed and shipped</b>.<br/><br/>
                 
              Kind regards,<br/>
                 
              TheCompany.
            </body>
          </html>
        ]]>
</activiti:expression>
    </activiti:field>  

         </extensionElements>
         <incoming>sid-15C370A0-B001-4529-A2E7-E68B60EB94FD</incoming>
      </serviceTask>
      <scriptTask completionQuantity="1" id="sid-64A7B10A-D832-4DC7-BD79-16A5BF97A624" isForCompensation="false" name="Application status &quot;onhold&quot;" scriptFormat="groovy" activiti:resultVariable="status" startQuantity="1">
         <extensionElements>
            <signavio:signavioMetaData metaKey="bgcolor" metaValue="#ffffcc"/>
         </extensionElements>
         <incoming>sid-8D20906C-5740-4007-B82B-C27F4DD3BEC0</incoming>
         <script>
def scriptVar = "applied"
    execution.setVariable("status", scriptVar)
         </script>
</scriptTask>
      <scriptTask completionQuantity="1" id="sid-CE7F2D73-599F-4D7D-96CE-58C9ED1AA0A7" isForCompensation="false" name="Application status &quot;progresseD&quot;" scriptFormat="groovy" activiti:resultVariable="status" startQuantity="1">
         <extensionElements>
            <signavio:signavioMetaData metaKey="bgcolor" metaValue="#ffffcc"/>
         </extensionElements>
         <incoming>sid-88ADB815-5985-4661-92C8-4B685E948A2F</incoming>
         <outgoing>sid-69951C3D-FA0F-4760-89FB-B793ED098495</outgoing>
         <script>
def scriptVar = "applied"
    execution.setVariable("status", scriptVar)
         </script>

      </scriptTask>
      <serviceTask completionQuantity="1" id="sid-2EE1D6DF-36B0-40EF-ADFC-79D954643339" activiti:type="mail" implementation="webService" isForCompensation="false" name="Email to applicant on status &quot;progressed&quot;" startQuantity="1">
         <extensionElements>
            <signavio:signavioMetaData metaKey="bgcolor" metaValue="#ffffcc"/>
<activiti:field name="from" stringValue="rajee_gaekwad@yahoo.co.in" />
    <activiti:field name="to" expression="${Email}" />
    <activiti:field name="subject" expression="Your order  has been shipped on ${status}" />
    <activiti:field name="html">
      <activiti:expression>
        <![CDATA[
          <html>
            <body>
              Hello Miss rajee,<br/><br/>
                
              As of your order has been <b>processed and shipped</b>.<br/><br/>
                 
              Kind regards,<br/>
                 
              TheCompany.
            </body>
          </html>
        ]]>
</activiti:expression>
    </activiti:field>  

         </extensionElements>
         <incoming>sid-69951C3D-FA0F-4760-89FB-B793ED098495</incoming>
      </serviceTask>
      <serviceTask completionQuantity="1" id="sid-718604A2-10BA-43EA-9A54-ED2E83EF494D" activiti:type="mail" implementation="webService" isForCompensation="false" name="Send notification email to admin" startQuantity="1">
         <extensionElements>
            <signavio:signavioMetaData metaKey="bgcolor" metaValue="#ffffcc"/>
<activiti:field name="from" stringValue="rajee_gaekwad@yahoo.co.in" />
    <activiti:field name="to" expression="${Email}" />
    <activiti:field name="subject" expression="Your order  has been shipped" />
    <activiti:field name="html">
      <activiti:expression>
        <![CDATA[
          <html>
            <body>
              Hello Miss rajee,<br/><br/>
                
              As of your order has been <b>processed and shipped</b>.<br/><br/>
                 
              Kind regards,<br/>
                 
              TheCompany.
            </body>
          </html>
        ]]>
</activiti:expression>
    </activiti:field>  

         </extensionElements>
         <incoming>sid-72438261-369F-497F-8A2A-32FC8876C0CC</incoming>
      </serviceTask>
      <serviceTask completionQuantity="1" id="sid-CFC6383D-B5EF-4C02-A847-57E78C966952" activiti:type="mail" implementation="webService" isForCompensation="false" name="Send email to applicant" startQuantity="1">
         <extensionElements>
            <signavio:signavioMetaData metaKey="bgcolor" metaValue="#ffffcc"/>
<activiti:field name="from" stringValue="rajee_gaekwad@yahoo.co.in" />
    <activiti:field name="to" expression="${Email}" />
    <activiti:field name="subject" expression="Your order  has been shipped" />
    <activiti:field name="html">
      <activiti:expression>
        <![CDATA[
          <html>
            <body>
              Hello Miss rajee,<br/><br/>
                
              As of your order has been <b>processed and shipped</b>.<br/><br/>
                 
              Kind regards,<br/>
                 
              TheCompany.
            </body>
          </html>
        ]]>
</activiti:expression>
    </activiti:field>  

         </extensionElements>
         <incoming>sid-549A038B-B1FD-4F49-92C1-4191596B285B</incoming>
      </serviceTask>

      <sequenceFlow id="sid-36728B93-2E8A-4077-859C-CC5A1DE98B3C" name="" sourceRef="sid-72D7810B-1C98-47B9-A42F-54525D9D75F7" targetRef="sid-82D76613-81AC-4A7A-BF0D-FDD15CE08F00"/>
      <sequenceFlow id="sid-757CB818-1947-4AEF-B5A5-7932A083B0ED" name="" sourceRef="sid-82D76613-81AC-4A7A-BF0D-FDD15CE08F00" targetRef="sid-483CA4AE-D7BD-4DFE-A0B8-6ED892C7B054"/>
      <sequenceFlow id="sid-549A038B-B1FD-4F49-92C1-4191596B285B" name="" sourceRef="sid-483CA4AE-D7BD-4DFE-A0B8-6ED892C7B054" targetRef="sid-CFC6383D-B5EF-4C02-A847-57E78C966952"/>
      <sequenceFlow id="sid-72438261-369F-497F-8A2A-32FC8876C0CC" name="" sourceRef="sid-483CA4AE-D7BD-4DFE-A0B8-6ED892C7B054" targetRef="sid-718604A2-10BA-43EA-9A54-ED2E83EF494D"/>
      <sequenceFlow id="sid-685A2BA3-278A-4648-B234-6D382C707660" name="" sourceRef="sid-483CA4AE-D7BD-4DFE-A0B8-6ED892C7B054" targetRef="sid-08848121-EB04-4B47-8F77-B4AD173027BE"/>
      <sequenceFlow id="sid-681CE2A6-A372-4D63-9227-2AB86BB37CDC" name="" sourceRef="sid-08848121-EB04-4B47-8F77-B4AD173027BE" targetRef="sid-39CA73FE-654B-4EBE-86EE-1465DB6A762C"/>
      <sequenceFlow id="sid-BE833B5F-8B2C-45E2-95F5-805CF31AC4B2" name="" sourceRef="sid-39CA73FE-654B-4EBE-86EE-1465DB6A762C" targetRef="sid-2636D6F5-7A35-42A1-ADE7-FE35D90AD1E2"/>
      <sequenceFlow id="sid-88ADB815-5985-4661-92C8-4B685E948A2F" name="No" sourceRef="sid-2636D6F5-7A35-42A1-ADE7-FE35D90AD1E2" targetRef="sid-CE7F2D73-599F-4D7D-96CE-58C9ED1AA0A7"/>
      <sequenceFlow id="sid-D2EDA943-BC3C-4C6F-840C-F411A9721875" name="Yes" sourceRef="sid-2636D6F5-7A35-42A1-ADE7-FE35D90AD1E2" targetRef="sid-13F6035B-B0E1-436D-92F2-C5F117B27769"/>
      <sequenceFlow id="sid-15C370A0-B001-4529-A2E7-E68B60EB94FD" name="" sourceRef="sid-13F6035B-B0E1-436D-92F2-C5F117B27769" targetRef="sid-E8837476-A72C-4DF8-BDB8-1ECA86AE6C00"/>
      <sequenceFlow id="sid-8D20906C-5740-4007-B82B-C27F4DD3BEC0" name="" sourceRef="sid-13F6035B-B0E1-436D-92F2-C5F117B27769" targetRef="sid-64A7B10A-D832-4DC7-BD79-16A5BF97A624"/>
      <sequenceFlow id="sid-69951C3D-FA0F-4760-89FB-B793ED098495" name="" sourceRef="sid-CE7F2D73-599F-4D7D-96CE-58C9ED1AA0A7" targetRef="sid-2EE1D6DF-36B0-40EF-ADFC-79D954643339"/>
   </process>

frederikherema1
Star Contributor
Star Contributor
I see you doing this in 2 script-tasks:

    def scriptVar = "applied"
    execution.setVariable("status", scriptVar)

Makes sense it is not updated and keeps on being "applied"…

kuldeepjindal09
Champ in-the-making
Champ in-the-making
I have  a mail task as below:
<activiti:field name="to">
          <activiti:string><![CDATA[xyz@gmail.com]]></activiti:string>
        </activiti:field>
Now i want the value of this colum in another service class.
Please let me know the procedure to do the thing?