Hi,
Is it possible to know the value of a variable that is in a Pool A from a task in a Pool B ?
I have a variable in my process A that changes value often. And my process B needs sometimes to know the value of this variable.
Maybe I can do that with the process Api.
Thanks in advance for your help.
Hello,
You can know the value of your variable at any moment , you have juste to use “Send message event” (In ur process where your variable gets her different values) and catch it in the other process with “Receive message event”
The process A (where the variable is) doesn’t know when the process B want to know the value. So I can’t do that. They are not synchronized.
This is the process B that need to read the value in process A.
I also found this function a few minutes ago. Now I search how to know the process ID.
EDIT : I think that Process A can send its Instance ID when the other processes begin.
Hi,
You need some kind of correlation key.
Do you have multiple process A and B instances running at the same time?
Are process A and B started independently or one after another?
Process A is unique. Process A start before all the other process.
Process B is multiple and is started independently some time after A.
if Process A is unique, the easiest might be to:
- retrieve the processDefinitionID:
final SearchOptionsBuilder builder = new SearchOptionsBuilder(0, 5);
builder.filter(ProcessDeploymentInfoSearchDescriptor.NAME, “My_ProcessA”);
final SearchResult searchRes = getProcessAPI().searchProcessDeploymentInfosStartedBy(userId, builder.done());
- retrieve Process A unique instance based on its processDefinitionId:
http://documentation.bonitasoft.com/list-open-instances-process
- from the process instance you can retrieve any variable value
Thanks francois.
I find a solution based on your idea.
Here is my code :
import org.bonitasoft.engine.search.*;
import org.bonitasoft.engine.bpm.process.ProcessInstance;
import org.bonitasoft.engine.bpm.process.ProcessInstanceSearchDescriptor;
// I search the process A
final SearchOptionsBuilder builder = new SearchOptionsBuilder(0, 5);
builder.filter(ProcessInstanceSearchDescriptor.NAME, “My_ProcessA”);
final SearchResult searchRes = apiAccessor.getProcessAPI().searchProcessInstances(builder.done());
// The process is unique so it is the first one in the result
Long processId = searchRes.getResult().get(0).getId();
// My variable is a boolean
Boolean test = apiAccessor.getProcessAPI().getProcessDataInstance(“My_VariableInA”, processId).getValue();