JBoss Community

Trying to set ActorId in On Entry Action - work item is null

created by jemmerling in jBPM - View the full discussion

Hi,

 

I am trying to implement an On Entry Action to set the ActorId for a work item.

 

More generally, what I am trying to do is to assign a task to a specific actor under certain circumstances. In the process definition, the ActorId is empty for the node however GroupId is specified. So ordinarily, some member of a group will claim the task, however given a certain condition, I want the task to be assigned to a specific actor.

 

This is probably the wrong way to do it, but I hope I am close.

 

So I implemented this On Entry Action, I can access the node instance but there is no work item (as opposed to the situation encountered in an On Exit Action):

 

System.out.println("* * * * * * * * * manager: " + manager + " * * * * * * * * * * * * * * * * ");

if (manager != null)
{
System.out.println("* * * * * * * * * setting ActorId to " + manager + " * * * * * * * * * * * * * * * * ");
WorkItemNodeInstance nodeInstance = (WorkItemNodeInstance)kcontext.getNodeInstance();
if (nodeInstance != null)
{
  WorkItem workItem = nodeInstance.getWorkItem();
  if (workItem != null)
  {
   System.out.println("* * * * * * * * * about to set ActorId to " + manager + " * * * * * * * * * * * * * * * * ");
   workItem.setParameter("ActorId", manager);
   String actorId = (String) workItem.getParameter("ActorId");
   System.out.println("* * * * * * * * * ActorId was set to " + actorId + " * * * * * * * * * * * * * * * * ");
  }
  else
  {
   System.out.println("* * * * * * * * * workItem was null * * * * * * * * * * * * * * * * ");
  }
}
else
{
  System.out.println("* * * * * * * * * nodeInstance was null * * * * * * * * * * * * * * * * ");
}
}
else
{
System.out.println("NOT setting ActorId");
}

 

Here is what is written to stdout:

 

* * * * * * * * * manager: pmanager2 * * * * * * * * * * * * * * * *

* * * * * * * * * setting ActorId to pmanager2 * * * * * * * * * * * * * * * *

* * * * * * * * * workItem was null * * * * * * * * * * * * * * * *

 

Can anybody see what I am trying to do and tell me what is the correct approach?

 

Thanks!

 

--JE

Reply to this message by going to Community

Start a new discussion in jBPM at Community