Putting my company directory into Google Sites with pictures

Posted on

Putting my company directory into Google Sites with pictures – Whether you’re just starting out with Google Sheets or are a seasoned pro, sooner or later one of your formulas will give you a formula or script parse error message rather than the result you want. However, every Formula user, irrespective of whether it’s a beginner or expert, has invariably come across a formula parse error in Google Sheets at least once in their life (and if you haven’t. you soon will). It can be frustrating, especially if it’s a longer formula where the formula parse error may not be obvious. In this article, we will talk about some common script or formula parse errors in Google Sheets, like Putting my company directory into Google Sites with pictures, and how to fix it.

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.

Answer :

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 !!

Leave a Reply

Your email address will not be published.