Doodle for your domain using Google Apps Script

I was looking on this post on Google Apps Developer blog, I thought, why not to develop the same functionality using Google Apps Script which will be easy to maintain and run. 

So I made a Spreadsheet Application which will does the same for you.

In this application, you just need to write the URL of the doodle and Date for that Doodle logo.

Services used in this application:

Here is the step by step instructions to use this Spreadsheet Application Doodle for your domain.

Note: This application can be used by Google Apps Administrator only.

Now your Doodle is setup. Once a doodle has been used, it will be archived in the second spreadsheet.



 //Setup a time driven trigger (Day Timer) to run this function/////////


function getTodaysDoodle(){


    var ss = SpreadsheetApp.getActiveSpreadsheet();

    var doodleSheet = ss.getSheets()[0];

    var timeZone = Session.getTimeZone();

    var dataRange = doodleSheet.getRange(2, 1, doodleSheet.getLastRow()-1, 3);

    var data = dataRange.getValues();

    var today = Utilities.formatDate(new Date(), timeZone, 'MM/dd/yyyy');

    var logo = {};

    var doodleRow = 2;

    for(var i=0; i<data.length; i++){

      var date = Utilities.formatDate(data[i][1], timeZone, 'MM/dd/yyyy');

      //if doodle exists, then get that doodle name and url

      if(date == today){ = data[i][0];

        logo.url = data[i][2];

        doodleRow = i+2;





    //If no doodle exists, get the domain default logo

    if( == null){ = data[0][0];

      logo.url = data[0][2];


      doodleSheet.getRange(2, 1, 1,3).setBackground('gold');



    //Archive the doodle in second sheet if it is not the default Logo

    if (doodleRow !=2){

      var archiveSheet = ss.getSheets()[1];

      doodleSheet.getRange(doodleRow, 1, 1,4)

.moveTo(archiveSheet.getRange(archiveSheet.getLastRow()+1, 1, 1));





    //If there occurs any error, Mail it to yourself

    GmailApp.sendEmail(Session.getEffectiveUser(), 'Error occured while updating' 

+'the Logo', 'Error'+e);



//This function will update the logo, called from ' getTodaysDoodle()'

function updateDoodle(logo){

  var logoBData = UrlFetchApp.fetch(logo.url).getContent();

  var logoB64encodedData = Utilities.base64Encode(logoBData);

  var xmlRaw = "<atom:entry xmlns:atom=''" +"xmlns:apps=''>"

      +"<apps:property name='logoImage' value='"+logoB64encodedData+"' />"


  var base = '';

  var fetchArgs = googleOAuth_("myDoodle", base);

  fetchArgs.method = 'PUT';

  fetchArgs.payload = xmlRaw;

  fetchArgs.contentType = 'application/atom+xml';

  var myDomain = UserManager.getDomain();

  var url = base+'2.0/'+myDomain+'/appearance/customLogo';

  var urlFetch = UrlFetchApp.fetch(url, fetchArgs); 

  var status = urlFetch.getResponseCode();



//Google oAuthConfig.. Called from 'updateDoodle(logo)'

function googleOAuth_(name,scope) {

  var oAuthConfig = UrlFetchApp.addOAuthService(name);






  return {oAuthServiceName:name, oAuthUseToken:"always"};


If you see any bug in this application or would like to give any feedback/comment, please drop your comment through this form.

Search Keywords: Doodle for your domain, Custom Logo for Google Apps, Doodle using GAS, Doodle using Google Apps Script, Google Apps Script tutorial Doodle, Doodle for your Google Apps Domain