[SOLVED] Working with bpm_groupAssignees in Activiti workflow

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2013 11:29 AM
I see a few, sparse examples of working with bpm_groupAssignees (note the plural - not groupAssignee) in jBPM only.
How does one get at the members from groupAssignees from an activiti workflow?
I imagine one would loop through the groups and individually do a getGroup on each group contained in bpm_groupAssignees.
I'm stuck on exactly how to get at groupAssignees from javascript in an activiti workflow.
Any help appreciated!
How does one get at the members from groupAssignees from an activiti workflow?
I imagine one would loop through the groups and individually do a getGroup on each group contained in bpm_groupAssignees.
I'm stuck on exactly how to get at groupAssignees from javascript in an activiti workflow.
Any help appreciated!
Labels:
- Labels:
-
Archive
6 REPLIES 6

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2013 01:47 PM
bpm_groupAssignees will be available as variable and should be an array. You should be able to do something like:
<javascript>
for(var i=0; i< bpm_groupAssignees.length; i++){
var group = groups.getGroup(bpm_Assignees );
}
</javascript>
If you see errors where your loop doesn't seem to be firing, try:
<javascript>
for(var i=0; i< bpm_groupAssignees.size(); i++){
var group = groups.getGroup(bpm_Assignees.get(i) );
}
</javascript>
Hopefully that helps. If you need more direction, provide more context on what you're trying to accomplish and I can elaborate.
<javascript>
for(var i=0; i< bpm_groupAssignees.length; i++){
var group = groups.getGroup(bpm_Assignees );
}
</javascript>
If you see errors where your loop doesn't seem to be firing, try:
<javascript>
for(var i=0; i< bpm_groupAssignees.size(); i++){
var group = groups.getGroup(bpm_Assignees.get(i) );
}
</javascript>
Hopefully that helps. If you need more direction, provide more context on what you're trying to accomplish and I can elaborate.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2013 05:51 PM
Thanks Max,
It did help to know that bpm_groupAssignees is merely an array.
What I want to do is allow a user to choose 1..N groups for a workflow instead of a single group.
Maybe I'm assuming too much, but I can't seem to run normal javascript functions inside ScriptTaskListener. Does it only allow a certain subset of javascript?
For example, if I try to use a simple 'for' loop as in your example, loading the workflow fails outright while starting Alfresco.
This simple task fails . . .
It did help to know that bpm_groupAssignees is merely an array.
What I want to do is allow a user to choose 1..N groups for a workflow instead of a single group.
Maybe I'm assuming too much, but I can't seem to run normal javascript functions inside ScriptTaskListener. Does it only allow a certain subset of javascript?
For example, if I try to use a simple 'for' loop as in your example, loading the workflow fails outright while starting Alfresco.
This simple task fails . . .
<activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener"> <activiti:field name="script"> <activiti:string> var x=10; for (var i=0; i < x; i++) { logger.log( "Number of loops: " + i ); } </activiti:string> </activiti:field> </activiti:taskListener>

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2013 06:29 PM
Looks like you're using the activiti script listener. logger is a root object provided by alfresco. If you're using the designer, try dragging out an alfresco script task and choosing alfresco script from the radio options.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2013 12:26 PM
I still seem unable to get at the actual groups in bpm_groupAssignees.
I want to loop through the groups, then pull the members of each group into an array.
Every method I've tried seems to say that 'group' is null.
groups.getGroup(bpm_groupAssignees doesn't seem to yield anything either.
Do I need to do something like – var group = groups.getGroup(bpm_groupAssignees.properties["cm:authorityName"]; ???? (which doesn't actually work either)
NOTE: logger is where I will have the array; I'm just trying to see if I can print the members for now.
I want to loop through the groups, then pull the members of each group into an array.
Every method I've tried seems to say that 'group' is null.
groups.getGroup(bpm_groupAssignees doesn't seem to yield anything either.
Do I need to do something like – var group = groups.getGroup(bpm_groupAssignees.properties["cm:authorityName"]; ???? (which doesn't actually work either)
NOTE: logger is where I will have the array; I'm just trying to see if I can print the members for now.
for(var i=0; i < bpm_groupAssignees.size(); i++){ var group = groups.getGroup(bpm_groupAssignees.get(i) ); var members = people.getMembers(group); for(var x in members) { logger.log("Member is: " + members[x].properties.userName); } }

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2013 11:36 AM
bpm_groupAssignees might return the group scriptnode, try something like
bpm_groupAssignees.properties.name
bpm_groupAssignees.properties.authorityName
I can't remember exactly where the shortname is stored.
bpm_groupAssignees.properties.name
bpm_groupAssignees.properties.authorityName
I can't remember exactly where the shortname is stored.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2013 04:38 PM
Yeah, that was it Max. I got it now. Thanks!!
logger.log( "Size is: " + bpm_groupAssignees.size() ); for(var i=0; i < bpm_groupAssignees.size(); i++){ var members = people.getMembers( bpm_groupAssignees.get(i) ); logger.log( "Groups are: " + bpm_groupAssignees.get(i).properties["cm:name"] ); for(var i in members) { memberNames.add(members.properties.userName); logger.log( "Members are: " + members.properties.userName ); }}
