Question

I'm struggling to get "bpm:outcome" variable in my task through a simple "complete" ScriptTaskListner. I add i'm using Activi WorkFlow Engine.

This is my attempt:

var import = task.getVariable('bpm_outcome');

It is strange...the value returned is "Next" (!!?!?)

Anyways...i've read that maybe this could do the job:

TaskInstance ti = ... ti.getVariableLocally("bpm_outcome");

or

ti.getVariable("bpm_outcome");

but i can't get the taskinstance...any suggestion? The other "wf:..." variables are perfectly captured with a simple task.getvariable attempt.

thanks in advance!

Was it helpful?

Solution

In Activity (unlike JBPM) there is no other outcome than Next/Done.

If you look at the default review and approve workflow of Alfresco, you'll notice they've introduced a new variable to see what the outcome is:

<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                        execution.setVariable('wf_reviewOutcome', task.getVariable('wf_reviewOutcome'));
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>

The task model:

<property name="wf:reviewOutcome">
                    <type>d:text</type>
                    <default>Reject</default>
                    <constraints>
                        <constraint name="wf:reviewOutcomeOptions" type="LIST">
                            <parameter name="allowedValues">
                                <list>
                                    <value>Approve</value>
                                    <value>Reject</value>
                                </list>
                            </parameter>
                        </constraint>
                    </constraints>
                </property>

The share config:

<field id="wf:reviewOutcome" label-id="workflow.field.outcome" set="response">
                  <control template="/org/alfresco/components/form/controls/workflow/activiti-transitions.ftl" />
               </field>

So Alfresco just uses a normal field to determine the outcome. So you syntax is ok, you just need to get the right variable. In this case it's task.getVariable('wf_reviewOutcome')

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top