Another dope idea from the yearbook guru @jentechnology.
I noticed that she was asking about a better way to store notes inside of a slidedeck. She uses Google Keep currently, but wondered if there is an add-on available.
I don’t know of one, but we can definitely build it! The properties service is a way to save data INSIDE a document. There are 3 different services available.
-
PropertiesService.getScriptProperties()
is for all the users of a specific script. -
PropertiesService.getDocumentProperties()
is for all the users of a single, specific document. -
PropertiesService.getUserProperties()
is for only the specific user saving the properties.
Each serves a specific purpose, and in this case we want to use the same properties in any slideshow that we use this add-on, so we are choosing the Script
properties. However, they are all used the same way!
Since the properties service is only capable of saving simple data, we can’t directly save an object, so we need to stringify it first. Below I am sharing two simple functions that allow you to save an array into the script properties.
function putTheme(theme) {
var props = JSON.parse(PropertiesService.getScriptProperties().getProperty('THEMES')) || [];
props.push(theme);
PropertiesService.getScriptProperties().setProperty('THEMES', JSON.stringify(props));
return props;
}
function getThemes() {
var props = JSON.parse(PropertiesService.getScriptProperties().getProperty('THEMES')) || [];
return props;
}
For the full code, check out the github repository! If you want to contribute, 1) fork the repo, 2) make changes, 3) share your changes back with the community!