Posts

Create a contact in gmail contacts

var thisContact = ContactsApp.createContact("First name", "Family Name", "theemail@gmail.com");

Debugging by logging information

Where you need to log it: Logger.log('The text you log'); To view the log, go to View->Logs. To debug a function, you can go to: Run->Debug Function->

Getting a yes/no response and text input

var userInterface = SpreadsheetApp.getUi();   var getResponse = userInterface.prompt('This is the title', 'This is the question', userInterface.ButtonSet.YES_NO);   if(getResponse.getSelectedButton() == userInterface.Button.YES)   {     Browser.msgBox("You said yes");     Browser.msgBox('You just keyed in:' + getResponse.getResponseText());   }else   {     Browser.msgBox("You said no");   }

Create a side bar

In Script editor, go to File -> New -> HTML file. Add in HTML code inside your file. function functionToShowSideBar() {  SpreadsheetApp.getUi().showSidebar(HtmlService.createHtmlOutputFromFile('NameOfHTMLFileCreated').setTitle("Hello")); } This bar will pop up at the right hand side of your sheets.

Create a submenu under Add ons

function onOpen() {   SpreadsheetApp.getUi().createAddonMenu().addItem("Show side bar", "functionToShowSideBar").addToUi();   } You use DocumentApp.getUi() if using google docs. Use SpreadsheetApp.getUi() if using google sheets.

Create a menu

Code: function makeMenu() {   DocumentApp.getUi().createMenu("Top Menu Text").addItem("Sub menu function is toastMe", "toastMe").addToUi(); } To make it load on startup, change function name to onOpen()