Discussion:
[jboss-user] [jBPM] - Passing work item results to process variables
David Harris
2013-05-02 22:34:59 UTC
Permalink
David Harris [https://community.jboss.org/people/dmwpepper] created the discussion

"Passing work item results to process variables"

To view the discussion, visit: https://community.jboss.org/message/811330#811330

--------------------------------------------------------------
In my executeWorkItem method, I have

Map<String,Object> results = new HashMap<String,Object>();
results.put("Source_IP", "333.33.333.33");
results.put("Start_Date", "1999 01 01");
results.put("End_Date", "2000 01 01");
manager.completeWorkItem(workItem.getId(),results);

Chapter 14 of the User Guide says:
Result Mapping: Allows you to map a result (returned once a work item has been executed) to a variable of the process.  This allows you to use results in the remainder of the process.

In Eclipse, there is a "Result Mapping" attribute associated with the service task.  Do I create an association between the results variable and the process variable by using the "Result Mapping" attribute?  The association seems to go in backwards.  In other words, the Parameter (work item) and Variable (process) only go in one way, so I can't put the work item result into the process variable.  I can only put the process variable into a work item result, which is the opposite of what I need to do.  So, I know I'm doing this wrong, but not sure how to do this with the Result Mapping, if that's the way its supposed to work. Thanks.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/811330#811330]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Andy McC
2013-05-03 16:37:44 UTC
Permalink
Andy McC [https://community.jboss.org/people/andymcc] created the discussion

"Re: Passing work item results to process variables"

To view the discussion, visit: https://community.jboss.org/message/811473#811473

--------------------------------------------------------------
Hi David

It looks like you and I are still walking on similar paths!

In case you've not seen it already this may be useful https://community.jboss.org/people/bpmn2user/blog/2011/02/21/jbpm5-example-for-forms-with-variables JBPM5 Example -  Human Task Forms with Variables.

Paragraph 4 suggests that output parameters need to be passed out separately and not as a map - but it was written two years ago so may be well out of date!

Regards

Andy McC
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/811473#811473]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
David Harris
2013-05-03 17:13:20 UTC
Permalink
David Harris [https://community.jboss.org/people/dmwpepper] created the discussion

"Re: Passing work item results to process variables"

To view the discussion, visit: https://community.jboss.org/message/811478#811478

--------------------------------------------------------------
Hey Andy, yep, the path to enlightenment gets bumpy here and there.  I didn't see this post, but did look through a number of others.  Having reviewed it, I'm still not sure what passing output parameters separately means.  Does that mean they're not captured in Eclipse/bpmn2, but instead are returned in a Java method/class?  What's the purpose of Result Mapping if it can't put the results of a task into process variables? 
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/811478#811478]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Mauricio Salatino
2013-05-05 12:59:04 UTC
Permalink
Mauricio Salatino [https://community.jboss.org/people/salaboy21] created the discussion

"Re: Passing work item results to process variables"

To view the discussion, visit: https://community.jboss.org/message/815842#815842

--------------------------------------------------------------
Hi David,
Did you check the Web Process Designer? That's definitely more updated than the Eclipse Plugin.
As you mention copying variables from the work item scope to the process scope and vice versa is something vital. You need to understand that for doing that you need to have the correct mappings in the process file and then make sure that your work item is filling the variables that the process is expecting to do the copy.
So for example let's say that you have a Process Variable called: String Customer_Name;

At process level you should have the variable defined. In your work item you will need to define the Customer_Name variable as an input variable if you want to display or use the content of the variable (maybe another activity change its value) and as an output variable if you want to override the process variable. These mappings will be something like this:

Customer_Name -> this is the process variable

Now inside the WorkItem
dataInputs:
in_Customer_Name -> This represents the internal Work Item variable, it's not yet mapped to the process variable

dataOutputs:
out_Customer_Name -> This represents the internal Work Item variable that will be copied back to the process, it's not yet mapped to the process variable

Assignments:
Customer_Name ---(Mapped to)--> in_Customer_Name    -> This will copy the value of the process variable to the work Item in_Customer_Name when the process reach the work item node
out_Customer_Name ---(Mapped to)--> Customer_Name   -> This will tell the process to override the process variable called Customer_Name with the value of the internal work item variable called                                                                                                        out_Customer_name.

This mechanism is being defined by the BPMN2 language, and for that reason you need to have that in your xml file.
Notice that your WorkItemHandler will only work with in_Customer_name and out_Customer_Name, that means that your Map<String, Object> params will need to have those keys or at least the ones defined in the dataOutputs in order to override the Process variables when you complete the WorkItemHandler.

Hope this helps

Cheers
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/815842#815842]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
David Harris
2013-05-07 14:11:15 UTC
Permalink
David Harris [https://community.jboss.org/people/dmwpepper] created the discussion

"Re: Passing work item results to process variables"

To view the discussion, visit: https://community.jboss.org/message/816526#816526

--------------------------------------------------------------
Hey Mauricio,

Thanks for your response.  I use Eclipse for the Java development piece, so I needed to understand how it worked in that IDE, though it will eventually be used in the Web Process Designer and JBPM Console. Your answer helps some, but I needed to understand what to do in the Java work item code.  I found a post on StackOverflow ( http://stackoverflow.com/questions/9433776/jbpm-how-to-get-workitemhandler-results http://stackoverflow.com/questions/9433776/jbpm-how-to-get-workitemhandler-results) that provided some hints no how to return the results in the work item so they can be used in the next service task.

Dave
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/816526#816526]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Loading...