• SOLVED Workflow Extract Process Variable Value

  • OpenKM has many interesting features, but requires some configuration process to show its full potential.
OpenKM has many interesting features, but requires some configuration process to show its full potential.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #40417  by alexwgordon
 
Hi Guys,

I'm trying to create a workflow that assigns tasks to users and I'm stuck at a part with the "Select" field (dropdown) in the form element. Basically the user who is assigned the original task will then pass the task off to someone else using the Select field (dropdown). How can I extract the value that the user selects from that dropdown and pass it into a decision node?

In the workflow backend, it's showing the value of the variable as this:
Code: Select all
{label=, name=value, width=150px, height=25px, readonly=false, type=simple, value=alex, data=, optionsData=, options=[{label=okmAdmin, value=okmAdmin, selected=false}, {label=reviewer, value=reviewer, selected=false}, {label=alex, value=alex, selected=true}], validators=[], table=, optionsQuery=, suggestion=, class=}
I want to get the value of "value" (which is "alex" in this case).

Any advice would be amazing! Thank you guys!
Last edited by alexwgordon on Thu Sep 03, 2015 6:09 pm, edited 1 time in total.
 #40439  by alexwgordon
 
Okay in case anyone else is new to Java and didn't get this, this is what I ended up doing. It was crazy simple, so apologies to everyone!
Code: Select all
package com.openkm.workflow.Approval2;

import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;
import com.openkm.bean.form.Select;

public class setNewReviewer implements ActionHandler {
    private static final long serialVersionUID = 1L;
    public String aktor;
 
    @Override
    public void execute(ExecutionContext executionContext) throws Exception {
    	Select useVar = (Select) executionContext.getContextInstance().getVariable("username");
    	
    	if (useVar != null) {
    		String useVal = useVar.getValue();  //returns string
    		executionContext.getContextInstance().setVariable("aktor", useVal);
		} else {
			executionContext.getContextInstance().setVariable("aktor", null);
		}
    }
}
 #40441  by jllort
 
Also consider:
Code: Select all
String value = "";

// It's for select of type simple, for multiple should do minimal changed ( remove break, etc. )
for (Option option : userVar.getOptions()) {
   if (option.isSelected()) {
   	value = option.getValue();
   	break;
   }
}

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.