In my workflow model I have an association to cm:person type, in share configuration I'm using the authority.ftl template to display it, how can I limit the available users to select from down to the members of one group ?
Asked
Active
Viewed 917 times
2 Answers
3
There s a few changes that I needed to do in order to achieve this:
You should pass a parameter to your authority.ftl in your share modules config file using a new control param:
<config evaluator="node-type" condition="my:customtype"> <forms> <form> <appearance> <field id="my:personproperty"> <control template="/org/alfresco/components/form/controls/authority.ftl"> <control-param name="filterString">mygroupname</control-param> </control>
In alfresco\web-extension\site-webscripts\org\alfresco\components\form\controls\authority.ftl, pass this param to the js picker:
picker.setOptions( { itemType: "${field.endpointType}", <#if field.control.params.filterString??> filterString: "${field.control.params.filterString}", </#if> multipleSelectMode: ${field.endpointMany?string}, itemFamily: "authority" });
- In alfresco\extension\templates\webscripts\org\alfresco\repository\forms\pickerchildren.get.js read and use the parameter to query in only the given group:
argsFilterString = args['filterString'] ... if (argsSelectableType == "cm:person") { findUsers(argsSearchTerm, argsFilterString, maxResults, results); } ... function findUsers(searchTerm, filterString, maxResults, results){ var paging = utils.createPaging(maxResults, -1); var searchResults = groups.searchUsers(searchTerm, paging, "lastName"); var groupmembers = null; if (filterString != null){ var group = groups.getGroup(filterString); var groupmembers = group.getAllUsers(); } // create person object for each result for each(var user in searchResults) { if (logger.isLoggingEnabled()) logger.log("found user = " + user.userName); var add=true; if (groupmembers != null ){ var ismember = false; for each (var p in groupmembers){ if (""+p.userName == ""+user.userName){//need to add +"" cause they are java strings! ismember = true; } } if (!ismember){ logger.log(user.userName+" is no member of group "+filterString); add=false; } } if(add){ // add to results results.push( { item: createPersonResult(user.person), selectable: true }); } } }

Stefan De Laet
- 1,409
- 11
- 20
-
thanks alot!!!, I'll build modified versions of these two files in my amp project. but what modifications should I do to be able to use the new files? – Basil Jan 19 '16 at 10:54
-
My first step is about the usage. In your modules share configuration file (share-config-custom.xml ?) you should add the control to the property field definition. I ve updated the answer to make it more clear. – Stefan De Laet Jan 19 '16 at 13:08
-
That's what I've done, I think I'm placing the files in the wrong directory, could you please tell me in what folder of the repo amp do these files go ? – Basil Jan 19 '16 at 14:16
-
I ve updated the path of authority.ftl to alfresco\web-extension\site-webscripts\org\alfresco\components\form\controls\authority.ftl . The locations mentionned are the locations they have in my jar file of my module. – Stefan De Laet Jan 19 '16 at 15:07
-
@StefanDeLaet Hi, just wanted to know if that "
mygroupname " will take the group name dynamic or hardcoded one?? like A is in Group1&2 and B is in Group1 so when A search then result will be from Group1&2 ..right? Apologise if it's a not a good question but I'm new to this – nikhil84 Feb 16 '17 at 18:42 -
It s a hard coded groupname yes, regardless of the groups of the current user – Stefan De Laet Feb 20 '17 at 09:01
1
You can create a new control based on that authority.ftl and authority-finder.js, in which you modify the webscript call to a limited number of users to be returned !
Note : If the webscript doesnot support maxItems parameter (or any other parameter to limit the number of results returned), you can always create your brand new webscript that supports that feature and then point your new control at it.

Younes Regaieg
- 4,156
- 2
- 21
- 37
-
actually I'm looking to make authority control search in users who are members of a certain group not limit the number of results, so please what part of authority-finder.js should I modify to accomplish this ? – Basil Jan 18 '16 at 21:10