Hopefully I am in the right place. I am working on building a maintenance program and I am having some trouble. What I have is a work order form created in sheets, I have a script wrote that will save a copy of the template under a new name (tied to a cell value in the sheet), a folder on drive. I also have this script scheduling the work order on a google calendar. This code is below.
function Create() {
var ss = SpreadsheetApp.getActiveSpreadsheet(); // Get spreadsheet
var id = ss.getId(); // Get spreadsheet ID
var sstocopy = DriveApp.getFileById(id); //Get spreadsheet with DriveApp
var sheet = ss.getActiveSheet(); // Grab the sheet in order to find the name of the new spreadsheet
to be created
var sheet_name = sheet.getRange("C4").getValue(); // Get the value, in this case: Project Urn
var folder = DriveApp.getFolderById("1D9gWUuHTPbWkzpSOp5vQdg-K8N6kUGo6"); // Get the folder where
the sheet needs to be placed.
sstocopy.makeCopy(sheet_name,folder); // Make the copy of the sheet in that folder.
var eventCal =
CalendarApp.getCalendarById("c_4um01s3eqvq7d5kqi0ga4i1098@group.calendar.google.com") ;
var eventname = sheet_name;
var eventstart = sheet.getRange("E3").getValue();
var eventstop = sheet.getRange("E4").getValue();
eventCal.createAllDayEvent(eventname, eventstart, eventstop);
}
Now this code works great, I originally had a clickable button on the sheet to run this code, and that worked great from the computer. The sticky part is that I want to be able to run this off the mobile app from a Ipad. So I have been trying to set up a drop down menu in order to run the script. My sheets file has several pages/tabs, and I think this is what is giving me issues. I am assuming that I need to call the right sheet but I can't seem to get it to work.
The first code I tried was this (except my drop down is in F3)
function onEdit(e) {
if (e.range.getA1Notation() == 'A1') {
if (/^\w+$/.test(e.value)) {
eval(e.value)();
e.range.clear();
}
}
}
But I get an undefined error for e.range.getA1Notation. I've tried some other things but I don't really know what I'm doing, as my understanding is pretty basic, and its been a long time since I really did anything like this. Any help would be appreciated.