I'm using this code to pull the name and emails of my users into an intranet page on Google Sites. I was just wondering, is there some code that I can add to this so I can retrieve pictures? I would imagine it goes in below flexTable.setWidget(parseInt(i), 1, app.createLabel(user.getEmail())); but I'm not sure what I can add there to retrieve their picture from their profile. I would also like to do the same for phone number.

function doGet() {
  var app = UiApp.createApplication(); 
  var users = UserManager.getAllUsers();  
  var flexTable = app.createFlexTable().setBorderWidth(1);

  for (var i=0, len=users.length; i<len; i++) {
    var user = users[i];
    flexTable.setWidget(parseInt(i), 0, app.createLabel(user.getGivenName()
      + ' ' + user.getFamilyName()));
    flexTable.setWidget(parseInt(i), 1, app.createLabel(user.getEmail()));
  return app;

Edit: I tried adding flexTable.setWidget(parseInt(i), 2, app.createLabel(user.getPhones())); but that gives me an error in the code. I got this from the API reference for scripts.

  • Perhaps you can post a solution? I will try as well. Jan 31, 2014 at 12:09

1 Answer 1


That's not possible I'm afraid with the API used. The API that's being used doesn't allow for more (basic) info to be retrieved.

There's however a new API released under Google Apps Script that can help you out:
Admin SDK Directory Service

This allows for much more tweaking !!

  • Ok thanks, I tried a few different attempts with the code above but as you said it doesn't allow for more info to be retrieved.
    – Ronan
    Jan 31, 2014 at 12:23
  • If I used your script for the spreadsheet version would I be able to manually enter the telephone numbers in the spreadsheet? I get this error in my script with the spreadsheet: "The coordinates or dimensions of the range are invalid. (line 9, file "Code")"
    – Ronan
    Jan 31, 2014 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.