Created
February 16, 2019 19:55
-
-
Save kurtkaiser/dd263991730624b7e94ac898d0f6a9c2 to your computer and use it in GitHub Desktop.
Properties in Google Apps Script is confusing. At least it was for me. I honestly spent a year avoiding using properties, I found saving variables as properties very frustrating. I use properties often and wanted to make a quick introduction to how properties in Apps Script work.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Kurt Kaiser | |
// kurtkaiser.us | |
// All Rights Reserved, 2019 | |
var scriptProperties = PropertiesService.getScriptProperties(); | |
function onOpen(){ | |
var ui = SpreadsheetApp.getUi(); | |
var response = ui.prompt('What is your favorite color?', ui.ButtonSet.OK); | |
scriptProperties.setProperty('color', response.getResponseText()); | |
ui.alert('Favorite color: ' + scriptProperties.getProperty('color')); | |
} | |
function myAlert(){ | |
var ui = SpreadsheetApp.getUi(); | |
ui.alert('Favorite color: ' + scriptProperties.getProperty('color')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment