Page 1 of 1
Workflow Path variable
PostPosted:Sun Aug 19, 2012 12:43 pm
by pmbsa
Hi, I am new to jBpm and I seem to be struggling with what I assumed would be a simple task.
I need to access the "path" variable that is automatically applied to each workflow so I can get to the document in question. No matter what I try I cannot seem to get to it.
I have created an Action Handler class that I have applied in various places to get this work but no joy (transitions, Task activities, you name it).
I have tried many methos but I must say I assumed something like this would work based on the jBpm documentation and the examples I have seen around the place.
executionContext.getContextInstance().getVariable("path");
It certainly doesnt though... Any advice would be genuinely appreciated please... at this point my laptop is in grave danger of meeting with a sticky end... its been a very frustrating
experience
thanks
Paul
Re: Workflow Path variable
PostPosted:Mon Aug 20, 2012 6:43 am
by jllort
You're doing something wrong but I can not understand what.
Here for example is a way to get a variable from a node:
Code: Select allpackage com.openkm.workflow.exercise.exercise5;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;
import com.openkm.bean.form.Input;
public class NodeAction implements ActionHandler {
private static final long serialVersionUID = 1L;
@Override
public void execute(ExecutionContext executionContext) throws Exception {
Input number = (Input) executionContext.getContextInstance().getVariable("number");
int value = 0;
if (number!=null) {
value = Integer.valueOf(number.getValue());
} else {
value = 0;
}
value = value * 3;
Input modified = new Input();
modified.setName("modified");
modified.setLabel("modified");
modified.setValue(String.valueOf(value*3));
executionContext.getContextInstance().setVariable("modified", modified);
}
}
Here we asume you got a input form called "number" you get the value added and then create a new input named "modified" that will be used in next form into data field.
In your case should be something so simply as String path = (String) executionContext.getContextInstance().getVariable("path"); adn then try to write into log as System.out.println("path: "+path);
Re: Workflow Path variable
PostPosted:Mon Aug 20, 2012 7:51 am
by pmbsa
Hi, thanks for the reply. I have tried exactly that but the logs reflect the path as null for some reason. Is doing my head in it must be said.
thanks
Paul
Re: Workflow Path variable
PostPosted:Mon Aug 20, 2012 3:59 pm
by jllort
Which openkm version are you using? Can you see the path in Dashboard workflow, the document link goto goes correctly ?
Re: Workflow Path variable
PostPosted:Mon Aug 20, 2012 6:06 pm
by pmbsa
Hi, I am using the community edition 5.1 edition of OpenKM and yes, the path information is displayed perfectly in the workflow Dashboard and the link works perfectly as well.
I have tried the same method in task, transitions, decisions, pretty much everywhere and the result is the same. null
thanks
Paul
Re: Workflow Path variable
PostPosted:Thu Aug 23, 2012 10:36 am
by pavila
"path" is not defined as process variable because can change while the workflow is running. Instead of the path try with the "uuid" process variable which will remain across the process instance life time.
Re: Workflow Path variable
PostPosted:Thu Aug 23, 2012 4:29 pm
by jllort
And with uuid using getNodePath from OKMRepository
http://doxygen.openkm.com/5.1.x/dd/d2c/ ... itory.html you can get the actual path.
Re: Workflow Path variable
PostPosted:Fri Aug 24, 2012 5:42 am
by pmbsa
Thanks for the pointers, I will have a go and see how I get on.
Re: Workflow Path variable
PostPosted:Sun Aug 26, 2012 1:54 pm
by pmbsa
Thanks for the advice. That approach worked a treat!