Having had my code fixed by @Tanaike here How to run a function when specific range is edited, I have copied my code to the live sheet and now face some issues.
Is it possible for my trigger to run onFormSubit
from a specific sheet (called 'ICU Request Form') and activate the sidebar in the Ui
on the active sheet (which will ALWAYS be 'Tech Dashboard').
function createTrigger(){
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("ICU Request Form")
ScriptApp.newTrigger('installableOnEdit')
.forSpreadsheet(ss)
.onFormSubmit()
.create()
}
function installableOnEdit(e){
var range = e.range;
var sheetName = e.source.getActiveSheet().getSheetName();
if (
sheetName == "ICU Request Form" &&
range.rowStart >= 2 &&
range.columnStart >=1 &&
range.rowStart <= 19 &&
range.columnStart <= 9 &&
!e.oldValue && e.value
) {
showSidebar();
}
}
var SIDEBAR_TITLE = 'Dashboard Notification!';
function onOpen(e) {
SpreadsheetApp.getUi()
.createAddonMenu()
.addItem('Show sidebar', 'showSidebar')
.addToUi();
}
function onInstall(e) {
onOpen(e);
}
function showSidebar() {
var ui = HtmlService.createTemplateFromFile('Sidebar')
.evaluate()
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
.setTitle(SIDEBAR_TITLE);
SpreadsheetApp.getUi().showSidebar(ui);
}
Here is a copy of the live page so any edits won't affect the program. The Script project is called 'Notifications'. https://docs.google.com/spreadsheets/d/1hxLMHoxjp4KHKXRTzwdeXJSGhEz_kOChDrB9NVDSZ1E/edit?usp=sharing