-
Notifications
You must be signed in to change notification settings - Fork 0
Home
#Welcome to the mettingMacroSheets wiki!
##Getting Started adding another Macro ###Adding sidebar You can start adding more Macros to she custom menu by copying the line from the onOpen function
.addItem('Points Meeting Macro', 'showSidebar')
Then change the name of the item and the function to call
Example:
.addItem('NAMEOFMACROHERE', 'FunctionToCallHere')
so it ends up looking like:
function onOpen() {
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.createMenu('Custom Menu')
.addItem('Points Meeting Macro', 'showSidebar')
.addItem('NAMEOFMACROHERE', 'FunctionToCallHere')
.addToUi();
}
You can create another html file using the already created one and adding any fields needed
then adding the function to call
Example:
function showSidebar() {
var ui = HtmlService.createHtmlOutputFromFile('sidebar') //gets the html from the file name sidebar.html
.setTitle('Record Points').setSandboxMode(HtmlService.SandboxMode.IFRAME); //names the sidebar that will show up Record Points
SpreadsheetApp.getUi().showSidebar(ui); // actually makes it show up on the UI
}
Following the example we added before where the function was called FunctionToCallHere
So possibly adding another one could look like this:
function FunctionToCallHere() {
var ui = HtmlService.createHtmlOutputFromFile('sidebar2') //gets the html from the file name sidebar2.html
.setTitle('Another Points').setSandboxMode(HtmlService.SandboxMode.IFRAME); //names the sidebar that will show up Record Points
SpreadsheetApp.getUi().showSidebar(ui); // actually makes it show up on the UI
}
###HTML Sending data to script
So in the html in sidebar.html there is a function called test thats get called on click
that is what sends the data to the script
function test(){
event.preventDefault();
...
google.script.run
.withSuccessHandler(complete)
.retrieveUserFields(data); //this is the name of the function you want called
}
So on click it calls test which calls the retrieveUserFields function
function retrieveUserFields(data)
{
//test();
compareSheet(data, regularPoints);
return true;
}
which calls comapreSheet with the data that is sent
create your own retrieveUserFields and send the data to it
then send it to compareSheet and use the appropriate function calculator and setup function needed