cancel
Showing results for 
Search instead for 
Did you mean: 

error: Failed to execute supplied script: missing ), trying to run an script on a user task

carolinamontes
Champ in-the-making
Champ in-the-making
Hello everybody, I´m kind of new in the alfresco's world. i´m customizing a workflow and I need that when the workflow ends, an aspect is added to the documents in the current workflow, until now I have not reach that point, due to the script I´m using, it's giving me the following error message:

<blockcode>
org.activiti.engine.ActivitiException: Exception while invoking TaskListener: Exception while invoking TaskListener: 07100442 Failed to execute supplied script: missing ) after condition (AlfrescoJS#4)
</blockcode>

in the alfresco log there is no error, it just the error that shows in the pop up alert.

everything works fine until I put this code…specifically from the "if (${estwf_reviewOutcome} == 'Aprovado'){" part:

<blockcode>
   <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
      <activiti:field name="script">
         <activiti:string>
                  execution.setVariable('estwf_reviewOutcome', task.getVariable('estwf_reviewOutcome'));
               execution.setVariable('bpm_comment', task.getVariable('bpm_comment'));
               if (${estwf_reviewOutcome} == 'Aprovado'){
                        if ((bpm_package != null) &amp;&amp; (bpm_package.children != null)) {
                         var i = 0;
                         for (i = 0; i &lt; bpm_package.children.length; i++) {
                           var document = bpm_package.children;
                           document.addAspect("wf:workflowOutcomeAspect");
                           document.properties["wf:workflowOutcome"] = "approved";
                           document.save();
                         }
                     }
               }         
          </activiti:string>
          </activiti:field>
     </activiti:taskListener>
</blockcode>


can anyone see what is wrong with this code? or how can I improve it?

Regards, Carolina
2 REPLIES 2

rjohnson
Star Contributor
Star Contributor
You seem to be using a sort of freemarker mark up on line 4. I suspect


if (${estwf_reviewOutcome} == 'Aprovado'){


should be


if (estwf_reviewOutcome == 'Aprovado'){


Good luck

Bob Johnson

Thanks Bob!!, it works in a certain way, after the change, a new error appeard:

<blockcode>
org.activiti.engine.ActivitiException: Exception while invoking TaskListener: Exception while invoking TaskListener: 07110148 Failed to execute supplied script: 07110147 ReferenceError: "estwf_reviewOutcome" is not defined. (AlfrescoJS#4)
</blockcode>

so I change the code to this:

<blockcode>
if (task.getVariable('estwf_reviewOutcome') == 'Aprovado'){
</blockcode>

and it works!

Regards, Carolina.