cancel
Showing results for 
Search instead for 
Did you mean: 

Send a value from workflow instantiation to ActionHandler

nicolasraoul
Star Contributor
Star Contributor
I am implementing a workflow.
In one of the action handlers, I need the "publicationMethod". This "publicationMethod" is known at the beginning of the workflow.
So if I understood well, I need a workflow variable.
But I can't seem to be able to make it work, and haven't found anything in the doc or via Google.
Here is what I tried:

When starting the workflow:
params.put(QName.createQName("{http://my/}publicationMethod"), publicationMethod);
WorkflowPath path = this.getWorkflowService().startWorkflow(this.selectedWorkflow, params);

In the workflow definition:
<action name="action" class="my.PublishActionHandler">
   <variable name="publicationMethod" access="read"/>
</action>

In the action handler:
public void execute(ExecutionContext context) throws Exception {
   String publicationMethod = (String)context.getVariable("publicationMethod");

But publicationMethod is null  😞
What is the proper way to achieve this?

Thanks a lot!
Nicolas
1 REPLY 1

nicolasraoul
Star Contributor
Star Contributor
I finally found a solution by trying any wild idea I could imagine. Here is the one that worked:

        <task-node name="review2">
                <task name="sec:reviewTask" swimlane="reviewer2" />
                <transition to="end" name="最終承認">
               <script>
                  <expression>
                     publicationMethod = sec_publicationMethod;
                  </expression>
                  <variable name="publicationMethod" access="write" />
               </script>
                   <action name="action" class="my.PublishActionHandler" />
                </transition>
        </task-node>

The other files are the same as posted earlier. sec is the prefix for my namespace.
Hope this helps someone after me!
Nicolas Raoul