Created
July 12, 2020 02:24
-
-
Save kurtkaiser/08b5431af1a6542e44c8f46f4d421ddd to your computer and use it in GitHub Desktop.
Google Apps Script Properties Service Video Demo
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
// Code.gs by Kurt Kaiser | |
var scriptProperties = PropertiesService.getScriptProperties(); | |
function onOpen() { | |
var ui = SpreadsheetApp.getUi(); | |
ui.createMenu('Properties Demo') | |
.addItem('Show Sidebar', 'showFormSidebar') | |
.addToUi(); | |
} | |
function showFormSidebar() { | |
var html = HtmlService.createHtmlOutputFromFile('Form') | |
.setTitle('Properties Demo') | |
SpreadsheetApp.getUi() | |
.showSidebar(html); | |
} | |
function saveSidebar(sideData){ | |
scriptProperties.setProperty('myColor', sideData.favColor); | |
scriptProperties.setProperty('myAnimal', sideData.animal); | |
} | |
<!-- Form.html --> | |
<!DOCTYPE html> | |
<html> | |
<body style="background: #0D9; color: blue"> | |
<form> | |
<h2> Favorite Color</h2> | |
<input type="text" name="favColor" value="none"/> | |
<h2>Animal</h2> | |
<select name="animal"> | |
<option value="bird">Bird</option> | |
<option value="dog">Dog</option> | |
<option value="fish">Fish</option> | |
</select> | |
<br><br> | |
<button id="submitBtn" type="button" onClick="sidebarSubmit()">Submit</button> | |
</form> | |
</body> | |
<script> | |
function sidebarSubmit(){ | |
google.script.run.saveSidebar(document.forms[0]); | |
} | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment