Reputation: 6472
Specifically users.
Currently I have script like this:
function findUsers(s) {
var users = UserManager.getAllUsers();
var r = new Array;
Logger.log("User Count" + users.length );
for( var i = 0 ; i < users.length ; i++ )
{
var u = users[i];
var n = formatUserName( u );
n = n.toUpperCase();
if( n.indexOf( s.toUpperCase() ) > -1 )
{
r.push(u);
}
}
return r;
}
This works, but is a little slow and I know it will get slower, as more users are migrated because of how UserManager.getAllUsers()
currently works
So before I go off and look at ways of 'caching' the domain data myself...I'm wondering if there is a efficient way to search for objects within our domain via APIs or GAScript objects?
When you use the control panel for the domain you can search, fast and efficiently...
For my current task, I may abandon searching the domain myself and require the correct user name.
Upvotes: 0
Views: 89
Reputation: 7965
Here are your choices
1) Make use of the Google Apps Profiles API ( https://developers.google.com/google-apps/profiles/#Retrieving ) from within Google Apps Script. This requires use of oAuth. If you haven't used oAuth, try the oAuth Service Library ( https://developers.google.com/apps-script/notable-script-libraries ) to ease your pain of getting it to work.
2) The second option is what you've already noted. Cache the results in, say, a spreadsheet.
3) Irrespective of 1 or 2, you should open an issue in the Issue tracker if there isn't one already.
Upvotes: 1