cancel
Showing results for 
Search instead for 
Did you mean: 

What is getPeople? Documentation?

cfox
Champ in-the-making
Champ in-the-making
I am writing a repository webscript to return a set of people and their attributes.  I found the built in webscript "people.get" which makes a call to getPeople.  What is the method getPeople?  Is it part of the Javascript api? or Java api?  Where is it documented?  Searching (with Google as well) the wiki does not yield any results.


// Get the args
var filter = args["filter"];
var maxResults = args["maxResults"];

// Get the collection of people
var peopleCollection = people.getPeople(filter, maxResults != null ? parseInt(maxResults) : 0);

// Pass the queried sites to the template
model.peoplelist = peopleCollection;

Craig
4 REPLIES 4

mrogers
Star Contributor
Star Contributor
It's Java Script API.

The documentation should be here.   (And is missing  Smiley Sad )
http://wiki.alfresco.com/wiki/3.2_JavaScript_API#People_API

The implementation is here.   And there's good javadoc describing the method you are calling.
org.alfresco.repo.jscript.People.

cfox
Champ in-the-making
Champ in-the-making
Is there any additional syntax that can be used with the filter string?
wildcards
exact match
grep syntax

ottopodo
Champ in-the-making
Champ in-the-making
Hello,
I'm trying to add an extra property to peopleCollection in people.get.js

// Get the args
var filter = args["filter"];
var maxResults = args["maxResults"];

// Get the collection of people
var peopleCollection = people.getPeople(filter, maxResults != null ? parseInt(maxResults) : 0);

for (var i=0; i<peopleCollection.length;i++) {
    peopleCollection[i].properties["isfriend"]=1;
}
// Pass the queried sites to the template
model.peoplelist = peopleCollection;

I receive an error "Cannot set property "isfriend" of undefined to "1".

Which is the correct way to add an "isfriend" extra property?
Marco

jevon
Champ in-the-making
Champ in-the-making
I was stumbling across this lack of documentation for two days until I finally worked out what was going on through extensive debugging and source code hunting. people.getPeople(filter) returns a list of NodeRefs, not People.

In order to use the results as Javascript objects (i.e. properties['userName']), you need to first search for the NodeRef. From alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/repository/site/membership/potentialmembers.get.js:

peopleFound = people.getPeople(filter, maxResults);
for (i = 0; i < peopleFound.length; i++) {
  username = search.findNode(peopleFound[i]).properties.userName;
  // …
}