Building a Gmail Contact search application
Now, we will create an application to search existing contacts. This application is able to search and list your Gmail Contacts in Sheets. Create a new Sheet and rename Sheet1
to Contacts
and set it up as shown in the following screenshot. Create a button and assign the function name searchContacts
to it, as you learned in the previous chapter.
Create the searchContacts
function as listed here:
function searchContacts(){ var SheetContacts = SpreadsheetApp.getActiveSpreadsheet() .getSheetByName("Contacts"); // Read input from cell A3 var searchCriteria = SheetContacts.getRange("A3").getValue(); // First 10 contacts. // [You can change this limit, but advised to keep small.] var numOfContacts = 10; // Clear existing sheet data SheetContacts.getRange(7,1,numOfContacts,4).clear();
Here, clear
is the Range
object's method to clear everything including format and formula, in a range of cells. You can use the clear
method of...