cancel
Showing results for 
Search instead for 
Did you mean: 

Form Property Value

lambav
Champ in-the-making
Champ in-the-making
Hi ,
I have few issues.
1.  I am having a state variable in my workflow which I want to change at every user task without taking input from user.
But somehow that is not happening.
<activiti:formProperty id="state" name="State" type="string" default="PENDING" variable="state" writable="false"></activiti:formProperty>
but if I use this property again in next user task
<activiti:formProperty id="state" name="State" type="string" value="COMPLETED" variable="state" writable="false"></activiti:formProperty>
it does not change

2. I need a task in which I do not need a user input at all and just want to change the state. that I was changing in user task. I tried a script task and that is also not setting the state property to me.
<scriptTask id="scripttask1" name="Terminated" activiti:autoStoreVariables="false">
       <script>
          execution.setVariable("state", "TERMINATED")
         </script>
    </scriptTask>

Would be great help if get a quick response.
7 REPLIES 7

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

I've taken process definition from activiti sources:
activiti:resultVariable="newProcessVariableName"


<definitions id="definitions"
  xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
  xmlns:activiti="http://activiti.org/bpmn"
  xmlns:modeler="http://activiti.com/modeler"
  modeler:version="2.0"
  targetNamespace="Examples">
 
  <process id="setScriptResultToProcessVariable">
 
    <startEvent id="theStart" />

    <scriptTask id="theScriptTaskWithExistingProcessVariableName" scriptFormat="juel" activiti:resultVariable="existingProcessVariableName">
      <script>#{echo}</script>
    </scriptTask>

    <scriptTask id="theScriptTaskWithNewProcessVariableName" scriptFormat="juel" activiti:resultVariable="newProcessVariableName">
      <script>#{execution.id}</script>
    </scriptTask>

    <scriptTask id="theScriptTaskWithNoResultVariable" scriptFormat="juel">
      <script>#{echo}</script>
    </scriptTask>

    <userTask id="theTask" name="keep-alive task" />

    <endEvent id="theEnd" />

    <sequenceFlow id="flow1" sourceRef="theStart" targetRef="theScriptTaskWithExistingProcessVariableName" />
    <sequenceFlow id="flow2" sourceRef="theScriptTaskWithExistingProcessVariableName" targetRef="theScriptTaskWithNewProcessVariableName" />
    <sequenceFlow id="flow3" sourceRef="theScriptTaskWithNewProcessVariableName" targetRef="theScriptTaskWithNoResultVariable" />
    <sequenceFlow id="flow6" sourceRef="theScriptTaskWithNoResultVariable" targetRef="theTask" />
    <sequenceFlow id="flow7" sourceRef="theTask" targetRef="theEnd" />
   
  </process>

</definitions>

lambav
Champ in-the-making
Champ in-the-making
<startEvent id="startevent1" name="Start" activiti:initiator="employeeName">
      <extensionElements>
        <activiti:formProperty id="state" name="State" type="string" default="PENDING"></activiti:formProperty>
      </extensionElements>
    </startEvent>

<scriptTask id="scripttask1" name="Terminated" scriptFormat="juel" activiti:resultVariable="state">
      <script>
    status="TERMINATED";
    execution.setVariable("state", status);
</script>
    </scriptTask>

Now I want to change the state variable value to some other value. But the value of state is not getting changed. I am trying to do it in the same way you mentioned. But state value is same "PENDING".

Moreover I want to change this value in usertask too. But that is also not getting changed. Can you please send me exact snippet.

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

    <scriptTask id="scripttask1" name="Terminated" scriptFormat="juel" activiti:resultVariable="status">
      <script>TERMINATED</script>
    </scriptTask>

If this won't work, create jUnit test and attach it to the thread.
Regards
Martin

lambav
Champ in-the-making
Champ in-the-making
This is not working. It is just a normal use-case. I have never thought it will be so difficult to update a form variable without taking input from user again. Cant i just update the variable.
1. I am not able to update a variable in another user task
2. I am even not able to update a variable in script task.

I put questions and then I need to wait for several hours to get a reply. and then I am not getting the right ans.

Thanks

frederikherema1
Star Contributor
Star Contributor
I put questions and then I need to wait for several hours to get a reply. and then I am not getting the right ans
People on the forum try really hard to answer all question, show some respect please. We're an open-source product and you're paying nothing, don't expect 24/7 instant response. Try reading the user guide first…

If you want to use a a script-task, use groovy or javascript as language instead, for richer support (execution.setVariable() will just work). Or, use Java to have compiled service-tasks…

lambav
Champ in-the-making
Champ in-the-making
Sorry, If you did not like my comments. I understand that you are busy and I am paying nothing. I have full respect for you guys.

I spent like 3 days on this issue. and read the user guide ( not complete though) but I did not find any answer.
I got this reply after 5 days. And that reply is again answering to my second question and first question is still not answered.

1 . I am not able to update a variable in another user task

I have one form variable for which I took an input from user. Then in next user task. I just want to update that value with some default value.

2. I am even not able to update a variable in script task.
When you do something like execution.setVariable()  . Updated value of variable is not shown when you go and check it in activiti-explorer my instances. form properties. But When I went to database to check the variable value it is showing me the updated one.
So seems to be a bug in activiti-explorer.

So my use case was just to update a variable , I tried it through user task and then through script task both. 

Out of frustation, I expected that whatever I will get in reply would be the answer to my question even if it takes 5 days. Sorry for my comments. hope you understand my point too.

jbarrez
Star Contributor
Star Contributor
> I got this reply after 5 days. And that reply is again answering to my second question and first question is still not answered.

You asked this question in the easter holiday. Practically the whole of US and Europe is having a holiday (including us). As Fred said, as an OSS project we can't give any SLA's on giving responses we do … during time which our employer pays us for.

1. Yes, we understand. The variable should be available, we have unit tests for this.

2. Your script task looks allright. In Explorer, you are probably seeing the audit data (which cannot change, it's audit data).
However, the variable values should be shown as updated.

So in general you are trying to update a variable which was submitted as a form value, right?
Both a task listener / service task with or without scripts work. If not, please prove it with a unit tets.

> hope you understand my point too.

We do.