cancel
Showing results for 
Search instead for 
Did you mean: 

Fails to set value of task property type

purohitsumit
Champ in-the-making
Champ in-the-making
Hi,

I have been trying to set values of property types defined in task model but values show up as ""
I am trying it in 2 cases:
1. Set value of property with a constant.
2. Set value of property in task#2 based on value received in task#1 using process variables



<startEvent id="alfrescoStartevent1" name="Alfresco start" activiti:formKey="alvexwfat:startTask">
    <!–  Velo_Update Sumit.Purohit@pnnl.gov –>
    <extensionElements>
          <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
            <activiti:field name="script">
              <activiti:string>
              execution.setVariable('alvexwfat_velophaseid', task.getVariableLocal('alvexwfat_velophaseid'));
              </activiti:string>
            </activiti:field>
          </activiti:taskListener>
          <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
            <activiti:field name="script">
              <activiti:string>execution.setVariable('alvexwfat_velophaseid', task.getVariableLocal('alvexwfat_velophaseid'));
              </activiti:string>
            </activiti:field>
          </activiti:taskListener>
        </extensionElements>
    </startEvent>

    <subProcess id="subprocess1" name="">
      <multiInstanceLoopCharacteristics isSequential="false" activiti:collection="${alvexwfat_subprocessKinds}" activiti:elementVariable="alvexwfat_subprocessKind">
        <completionCondition>${alvexwfat_mainTaskDone}</completionCondition>
      </multiInstanceLoopCharacteristics>
      <exclusiveGateway id="exclusivegateway3" name="Exclusive Gateway"></exclusiveGateway>
      <userTask id="alfrescoUsertask1" name="Perform a Execute task" activiti:assignee="${executeTaskAssignee}" activiti:formKey="alvexwfat:executeTask">
        <extensionElements>
          <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
            <activiti:field name="script">
              <activiti:string>
              task.setVariableLocal('alvexwfat_testval','bla  bla again testval');
               task.setVariableLocal('alvexwfat_velophaseid', execution.getVariable('alvexwfat_velophaseid'));

</activiti:string>
            </activiti:field>
          </activiti:taskListener>
          <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
            <activiti:field name="script">
              <activiti:string>task.setVariableLocal('alvexwfat_velophaseid', "exectask phaseid complete");
            </activiti:field>
          </activiti:taskListener>
        </extensionElements>
      </userTask>



but instead, i get  :

 

alvexwfat_testval
   
   ""
alvexwfat_velophaseid
   
   ""


Am i doing it wrong ?

Thanks
Sumit
3 REPLIES 3

douglascrp
World-Class Innovator
World-Class Innovator
Hey, how are you?

I saw you are using a different way to get and set variables values than I use.

The way I do that is like this:

execution.setVariable('wf_reviewOutcome', task.getVariable('csigwf_reviseOutcome'));

while you use:
execution.setVariable('alvexwfat_velophaseid', task.getVariableLocal('alvexwfat_velophaseid'));

The difference are on getVariable and getVariableLocal calls.

And to set the task property on the create listener, I use this:

task.description = comentarioRevisor;

At least for ootb task properties, it works well.

Another sample code I've just found on another project:

task.setVariable('wfcv_localizacao', getLocalizacao(bpm_package));

In this case, it's a custom property, and on this case, I use setVariable again, not setVariableLocal.

Try these changes and let me know if they solved your problem.

Hi douglascrp,

Thanks for your reply.
"task.getVariable" worked but in order to set a variable value i get "field not available in model" error IF i use it as "task.<field-name>".
Only "task.setVariable" worked.

I am using alfresco 4.2-f

Thanks
–Sumit

douglascrp
World-Class Innovator
World-Class Innovator
I didn't get your problem.
Can you elaborate it?

Is is working or not?