I'm trying to do two things:
- Query
AdminDirectory.Users.list
byname
field to return a list of anyone whose name matches a given string (even partially) - If possible, prevent the email address field from being included in the search
For example, "donald" should return data for the users Donald Duck, Donald Trump, and Ronald McDonald. If someone searched for "onald", that should work too.
The below sort of works. In the "donald" scenario, it would return only Donald Duck's data. For some reason it won't return more than one user.
function processForm(formObject) { // formObject comes from form on front end
var textSearchObject = formObject.textSearch; // "donald"
var userList = AdminDirectory.Users.list({
domain: 'somedomain.com',
query: "name:'" + textSearchObject + "'",
viewType: 'domain_public',
projection: 'full'
}).users;
return userList;
}
I know, query: "name:'" + textSearchObject + "'"
looks very strange and most people would just use query: textSearchObject
. The problem is that this searches email addresses - I need to avoid this if possible.