Maciej Swiderski [
https://community.jboss.org/people/swiderski.maciej] created the
discussion
"Re: Dynamic User Task assignment"
To view the discussion, visit:
https://community.jboss.org/message/787277#787277
--------------------------------------------------------------
Franck cdsosi wrote:
1. Is the use of a variable as potential owner (e.g. #{employee}) the "good"
way to handle this kind of situation?
yes, I would say that this is the recommended way of handling dynamic assignment
Franck cdsosi wrote:
1. is possible to set it as group id?
yes, it is treated as any other input parameter that is passed to work item
handler. Please note (as Evaluation example illustrates) group assignments is done by
specifying data input named GroupId and then you can leave potential owner empty but the
construct must be there otherwise parser will complain.
Franck cdsosi wrote:
1. other way or solution to set dynamically my actor or group ID? Can a User Task actor
or group id be left blank and assigned programmatically? => I've read somewhere
that when a user Task is reached at process runtime it must assigned to an actor or group
at least Administrator. => "By default, jBPM registers a special user with userId
"Administrator" as the administrator of each task. You should therefor make sure
that you always define at least a user "Adminstrator" when registering the list
of valid users at the task service." This sentence let me think that no specific
actor can be set when modeling a BPMN process? Is it correct?
in general the best practice is to use process variables to refer to the actual
assignee (regardless if it's an actor or a group). The other story is on how do you
get the proper value for that variable. One and the simplest way is to ask for it when
process starts but of course that is not the only way. Since this is process variable it
can be set by other tasks (outcome of a service task), it can be set by business rule
since you can access process instance in drools rule, can be set when signaling with event
data, etc.
You're right the main requirement for user tasks is that there must be at least one
valid business administrator by valid I mean it must be known to the task service. There
are two ways of informing task service about users and groups:
* use UserGroupCallback to load users and groups on demand - recommended
* prepopulate task service db with all users and groups
Franck cdsosi wrote:
1. Where do I have to plug my specific User Task assignment algorithm? Can it be for
instance in an On-Entry script of the User Task or is it too late? If too late is the
answer where can I plug it (I hope there is no need to model a specific Task (Service
Task) before the User Task?
you could have a dedicated service that decides about assignment and then use that
service in one of the following ways:
* define a dedicated service task node that will contact the service and get the right
assignee based on some input
* define a rule that will contact the service ....
* use on entry (not a big fun of putting it there as it's hidden)
* if the service is not complex and does not have dependencies to outside world you could
make it as process variable and when assigning data input/potential owner call a method of
that process variable
Franck cdsosi wrote:
1. Is it possible to make a User Task assignment with a Drools rule?
as mentioned above, yes it is possible to prepare process variable that will be
used to assign people to the task. Most likely it would be possible to use task
service/client inside the rule consequence to do the assignment post task creation but I
think it is too complex for the case.
Moreover there is a rule base inside the task service session that has access to task and
its data (like potential owners) so defining rules there is yet another option. Please
note that to use that I believe it must be initialized differently than what demo setup
does so most likely it cannot be shown on demo installation.
HTH
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/787277#787277]
Start a new discussion in jBPM at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]