Cell reference out of range, Summary of failures for Google Apps Script: Add Row












0















I can not figure out why I keep getting this error when the script trigger runs:



Screen shot of script error



I do not see the Add Row function anywhere in this script however it is in the appscript.json script. Why am I getting this error and can I stop it?



Here is the script that runs on the trigger:






// This script sends an e-mail to the rep when a pick up is complete, stamps the pick up data in the Report tab, and adds the job to the Check In tab

function pickUpEmail() {

var ss = SpreadsheetApp.getActiveSpreadsheet(); // gets active spreadsheet
var checkin = ss.getSheetByName("Check In"); //gets the Check In tab
var app = ss.getSheetByName("App"); /// gets the App tab
var report = ss.getSheetByName("Report"); //gets the Report tab
var activatedSheetName = ss.getActiveSheet().getName();
var activeCell = app.getActiveCell(); //gets the active cell
var activeRow = activeCell.getRow(); //gets the row of the active cell
var activeColumn = activeCell.getColumn(); //gets the column of the active cell
var job = app.getRange(activeRow, 1).getValue(); //gets the job #
var jobRaw = app.getRange(activeRow,49).getDisplayValue(); //gets the raw job # (no EWR- prefix)
var duration = app.getRange(activeRow,50).getDisplayValue() //gets the duration
var date = app.getRange(activeRow, 3).getValue(); //gets the pick up date
var contact = app.getRange(activeRow, 5).getValue(); //gets the contact
var address = app.getRange(activeRow, 6).getValue(); //gets the address
var rep = app.getRange(activeRow, 52).getValue(); // gets the rep
var arrived = app.getRange(activeRow, 13).getDisplayValue(); //gets the arrival time
var departed = app.getRange(activeRow, 14).getDisplayValue(); //gets the departed time
var status = app.getRange(activeRow, 45).getDisplayValue(); //gets the pick up status
var type = app.getRange(activeRow,53).getDisplayValue(); //gets the job type

// Condition 1: if sheet is "App"
if (activatedSheetName == "App") {


//Reps

if (rep == "MM") {
var repname = "Mike";
var repEmailAddress = "mmolter@cratersandfreightersnynj.com";}

if (rep == "AG") {
var repname = "Ariel";
var repEmailAddress = "agalayda@cratersandfreightersnynj.com";}

if (rep == "JM") {
var repname = "Joe";
var repEmailAddress = "mmolter@cratersandfreightersnynj.com";}

if (rep == "CH" || rep =="CA") {
var repname = "Christina";
var repEmailAddress = "mmolter@cratersandfreightersnynj.com";}

if (rep == "CK") {
var repname = "Caroline";
var repEmailAddress = "ckopko@cratersandfreightersnynj.com";}

if (rep == "TR") {
var repname = "Tom";
var repEmailAddress = "tom@cratersandfreightersnynj.com";}

if (rep == "RP") {
var repname = "Robert";
var repEmailAddress = "rpoirier@cratersandfreightersnynj.com";}




if (type == "Pick up") {var emailText = "picked up!";}
if (type == "Delivery") {var emailText = "delivered!";}

// Condition 2: if active column is 14 (N)
if (activeColumn == 14) {



// Paste to Check ins

// Condition 3: if the status is "Completed"

if (status == "Completed"){


var inputRow = 1
checkin.insertRowAfter(inputRow);
var jobPaste = checkin.getRange(2,2).setValue(job);
var datePaste = checkin.getRange(2,4).setValue(date);
var repPaste = checkin.getRange(2,3).setValue(rep);


// Paste to Pick up Report
report.insertRowAfter(inputRow);
report.getRange(2,1).setValue(date); // Date
report.getRange(2,2).setValue(job); //Job Number
report.getRange(2,3).setValue(arrived); //Arrived
report.getRange(2,4).setValue(departed); //Departed
report.getRange(2,5).setValue(duration); //Status
report.getRange(2,6).setValue(type); //Type

// this whole section below take photos from the AppSheet folder, searches for the job # in the Shared Company Photos, and either makes a new folder if not existing, or copies them to it
var par_fdr = DriveApp.getFolderById("0B6lqZvelcxkeaWNZMmhKd0JDbjQ"); // Destination folder "Shared Company Photos"
var fdr_name = jobRaw;

try {
var newFdr = par_fdr.getFoldersByName(fdr_name).next();
newFdr.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.EDIT);
}
catch(e) {
var newFdr = par_fdr.createFolder(fdr_name);
newFdr.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.EDIT);
}

var search1 = "title contains ";
var search2 = "'" + jobRaw + "'";
var searchFor= search1+search2;
var fileIds=;
var files = DriveApp.getFolderById("16OkPTUa98pYPrDgJDATzRKTbq5h8_PcX").searchFiles(searchFor); // Source folder "App_Images"
var URL= ;
var link= "https://drive.google.com/uc?export=download&id=";

while (files.hasNext()) {
var file = files.next();

var copyFiles = file.makeCopy(jobRaw+"_on site",newFdr);
var fileId = copyFiles.getId();// To get FileId of the file
fileIds.push(link+fileId+"<P>");

// file.setTrashed(true);
}



var sig = "<p>Thank you,<p><b>The Road Crew<br><font color='#351C75'>Craters & Freighters</font color></b><br>333 Cedar Ave.<br>Middlesex, NJ 08846<br>732-563-9200-Tel<br>732-563-2221-Fax<br>";


var message =
"<font face='tahoma'>Hi "+ repname+","+
"<P>Your job<b> " +job+"</b> has been "+emailText+
"<p>"+contact+
"<br>"+address+
"<p><b>Arrived: </b>" +arrived+
"<br><b>Departed: </b>" +departed+
"<p><b>Time on site: </b>" +duration+
"<div id='pics' style='display: none;'><b>Pictures:</b><p>"+fileIds+
"</div>"+sig;


var bcc1 = "tom@cratersandfreightersnynj.com,mmolter@cratersandfreightersnynj.com,rpoirier@cratersandfreightersnynj.com,kkull@cratersandfreightersnynj.com";
var subject = job;
subject += " "+emailText;
MailApp.sendEmail(repEmailAddress, subject + "", message, {htmlBody: message, name: 'C&F Road Crew', bcc: bcc1});


// end of conditions 1,2,3
}}}

}





Here is the .json file:






{
"timeZone": "America/New_York",
"dependencies": {
"enabledAdvancedServices": [{
"userSymbol": "Drive",
"serviceId": "drive",
"version": "v2"
}, {
"userSymbol": "Calendar",
"serviceId": "calendar",
"version": "v3"
}],
"libraries": [{
"userSymbol": "AddRow",
"libraryId": "164YbqtkyuQe4ObDI-oxi8pY7pvoXxYhJq_J5i51pcxtu0QrdlhHdj11_",
"version": "2"
}]
},
"webapp": {
"access": "ANYONE_ANONYMOUS",
"executeAs": "USER_DEPLOYING"
},
"exceptionLogging": "STACKDRIVER",
"executionApi": {
"access": "ANYONE"
}
}












share|improve this question




















  • 3





    please edit your question and include a minimal example. there is not enough information here to recreate the issue

    – DaImTo
    Nov 26 '18 at 1:27











  • There are several kinds of triggers. What kind of trigger is your question about?

    – Rubén
    Nov 26 '18 at 2:02











  • I re-posted the question with supporting scripts sorry if it is too much to post

    – Robert P
    Nov 27 '18 at 14:33











  • "Add Row" is the name of the Script project, not the name of a function. Which one is the code line 7 of checkInEmail file?

    – Rubén
    Nov 27 '18 at 21:16











  • That 's just it, I can not find a Script Project Add Row. Line 7 in the checkinemail script is var checkin = ss.getSheetByName("Check In"), //gets the Check In tab

    – Robert P
    Nov 28 '18 at 23:25
















0















I can not figure out why I keep getting this error when the script trigger runs:



Screen shot of script error



I do not see the Add Row function anywhere in this script however it is in the appscript.json script. Why am I getting this error and can I stop it?



Here is the script that runs on the trigger:






// This script sends an e-mail to the rep when a pick up is complete, stamps the pick up data in the Report tab, and adds the job to the Check In tab

function pickUpEmail() {

var ss = SpreadsheetApp.getActiveSpreadsheet(); // gets active spreadsheet
var checkin = ss.getSheetByName("Check In"); //gets the Check In tab
var app = ss.getSheetByName("App"); /// gets the App tab
var report = ss.getSheetByName("Report"); //gets the Report tab
var activatedSheetName = ss.getActiveSheet().getName();
var activeCell = app.getActiveCell(); //gets the active cell
var activeRow = activeCell.getRow(); //gets the row of the active cell
var activeColumn = activeCell.getColumn(); //gets the column of the active cell
var job = app.getRange(activeRow, 1).getValue(); //gets the job #
var jobRaw = app.getRange(activeRow,49).getDisplayValue(); //gets the raw job # (no EWR- prefix)
var duration = app.getRange(activeRow,50).getDisplayValue() //gets the duration
var date = app.getRange(activeRow, 3).getValue(); //gets the pick up date
var contact = app.getRange(activeRow, 5).getValue(); //gets the contact
var address = app.getRange(activeRow, 6).getValue(); //gets the address
var rep = app.getRange(activeRow, 52).getValue(); // gets the rep
var arrived = app.getRange(activeRow, 13).getDisplayValue(); //gets the arrival time
var departed = app.getRange(activeRow, 14).getDisplayValue(); //gets the departed time
var status = app.getRange(activeRow, 45).getDisplayValue(); //gets the pick up status
var type = app.getRange(activeRow,53).getDisplayValue(); //gets the job type

// Condition 1: if sheet is "App"
if (activatedSheetName == "App") {


//Reps

if (rep == "MM") {
var repname = "Mike";
var repEmailAddress = "mmolter@cratersandfreightersnynj.com";}

if (rep == "AG") {
var repname = "Ariel";
var repEmailAddress = "agalayda@cratersandfreightersnynj.com";}

if (rep == "JM") {
var repname = "Joe";
var repEmailAddress = "mmolter@cratersandfreightersnynj.com";}

if (rep == "CH" || rep =="CA") {
var repname = "Christina";
var repEmailAddress = "mmolter@cratersandfreightersnynj.com";}

if (rep == "CK") {
var repname = "Caroline";
var repEmailAddress = "ckopko@cratersandfreightersnynj.com";}

if (rep == "TR") {
var repname = "Tom";
var repEmailAddress = "tom@cratersandfreightersnynj.com";}

if (rep == "RP") {
var repname = "Robert";
var repEmailAddress = "rpoirier@cratersandfreightersnynj.com";}




if (type == "Pick up") {var emailText = "picked up!";}
if (type == "Delivery") {var emailText = "delivered!";}

// Condition 2: if active column is 14 (N)
if (activeColumn == 14) {



// Paste to Check ins

// Condition 3: if the status is "Completed"

if (status == "Completed"){


var inputRow = 1
checkin.insertRowAfter(inputRow);
var jobPaste = checkin.getRange(2,2).setValue(job);
var datePaste = checkin.getRange(2,4).setValue(date);
var repPaste = checkin.getRange(2,3).setValue(rep);


// Paste to Pick up Report
report.insertRowAfter(inputRow);
report.getRange(2,1).setValue(date); // Date
report.getRange(2,2).setValue(job); //Job Number
report.getRange(2,3).setValue(arrived); //Arrived
report.getRange(2,4).setValue(departed); //Departed
report.getRange(2,5).setValue(duration); //Status
report.getRange(2,6).setValue(type); //Type

// this whole section below take photos from the AppSheet folder, searches for the job # in the Shared Company Photos, and either makes a new folder if not existing, or copies them to it
var par_fdr = DriveApp.getFolderById("0B6lqZvelcxkeaWNZMmhKd0JDbjQ"); // Destination folder "Shared Company Photos"
var fdr_name = jobRaw;

try {
var newFdr = par_fdr.getFoldersByName(fdr_name).next();
newFdr.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.EDIT);
}
catch(e) {
var newFdr = par_fdr.createFolder(fdr_name);
newFdr.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.EDIT);
}

var search1 = "title contains ";
var search2 = "'" + jobRaw + "'";
var searchFor= search1+search2;
var fileIds=;
var files = DriveApp.getFolderById("16OkPTUa98pYPrDgJDATzRKTbq5h8_PcX").searchFiles(searchFor); // Source folder "App_Images"
var URL= ;
var link= "https://drive.google.com/uc?export=download&id=";

while (files.hasNext()) {
var file = files.next();

var copyFiles = file.makeCopy(jobRaw+"_on site",newFdr);
var fileId = copyFiles.getId();// To get FileId of the file
fileIds.push(link+fileId+"<P>");

// file.setTrashed(true);
}



var sig = "<p>Thank you,<p><b>The Road Crew<br><font color='#351C75'>Craters & Freighters</font color></b><br>333 Cedar Ave.<br>Middlesex, NJ 08846<br>732-563-9200-Tel<br>732-563-2221-Fax<br>";


var message =
"<font face='tahoma'>Hi "+ repname+","+
"<P>Your job<b> " +job+"</b> has been "+emailText+
"<p>"+contact+
"<br>"+address+
"<p><b>Arrived: </b>" +arrived+
"<br><b>Departed: </b>" +departed+
"<p><b>Time on site: </b>" +duration+
"<div id='pics' style='display: none;'><b>Pictures:</b><p>"+fileIds+
"</div>"+sig;


var bcc1 = "tom@cratersandfreightersnynj.com,mmolter@cratersandfreightersnynj.com,rpoirier@cratersandfreightersnynj.com,kkull@cratersandfreightersnynj.com";
var subject = job;
subject += " "+emailText;
MailApp.sendEmail(repEmailAddress, subject + "", message, {htmlBody: message, name: 'C&F Road Crew', bcc: bcc1});


// end of conditions 1,2,3
}}}

}





Here is the .json file:






{
"timeZone": "America/New_York",
"dependencies": {
"enabledAdvancedServices": [{
"userSymbol": "Drive",
"serviceId": "drive",
"version": "v2"
}, {
"userSymbol": "Calendar",
"serviceId": "calendar",
"version": "v3"
}],
"libraries": [{
"userSymbol": "AddRow",
"libraryId": "164YbqtkyuQe4ObDI-oxi8pY7pvoXxYhJq_J5i51pcxtu0QrdlhHdj11_",
"version": "2"
}]
},
"webapp": {
"access": "ANYONE_ANONYMOUS",
"executeAs": "USER_DEPLOYING"
},
"exceptionLogging": "STACKDRIVER",
"executionApi": {
"access": "ANYONE"
}
}












share|improve this question




















  • 3





    please edit your question and include a minimal example. there is not enough information here to recreate the issue

    – DaImTo
    Nov 26 '18 at 1:27











  • There are several kinds of triggers. What kind of trigger is your question about?

    – Rubén
    Nov 26 '18 at 2:02











  • I re-posted the question with supporting scripts sorry if it is too much to post

    – Robert P
    Nov 27 '18 at 14:33











  • "Add Row" is the name of the Script project, not the name of a function. Which one is the code line 7 of checkInEmail file?

    – Rubén
    Nov 27 '18 at 21:16











  • That 's just it, I can not find a Script Project Add Row. Line 7 in the checkinemail script is var checkin = ss.getSheetByName("Check In"), //gets the Check In tab

    – Robert P
    Nov 28 '18 at 23:25














0












0








0








I can not figure out why I keep getting this error when the script trigger runs:



Screen shot of script error



I do not see the Add Row function anywhere in this script however it is in the appscript.json script. Why am I getting this error and can I stop it?



Here is the script that runs on the trigger:






// This script sends an e-mail to the rep when a pick up is complete, stamps the pick up data in the Report tab, and adds the job to the Check In tab

function pickUpEmail() {

var ss = SpreadsheetApp.getActiveSpreadsheet(); // gets active spreadsheet
var checkin = ss.getSheetByName("Check In"); //gets the Check In tab
var app = ss.getSheetByName("App"); /// gets the App tab
var report = ss.getSheetByName("Report"); //gets the Report tab
var activatedSheetName = ss.getActiveSheet().getName();
var activeCell = app.getActiveCell(); //gets the active cell
var activeRow = activeCell.getRow(); //gets the row of the active cell
var activeColumn = activeCell.getColumn(); //gets the column of the active cell
var job = app.getRange(activeRow, 1).getValue(); //gets the job #
var jobRaw = app.getRange(activeRow,49).getDisplayValue(); //gets the raw job # (no EWR- prefix)
var duration = app.getRange(activeRow,50).getDisplayValue() //gets the duration
var date = app.getRange(activeRow, 3).getValue(); //gets the pick up date
var contact = app.getRange(activeRow, 5).getValue(); //gets the contact
var address = app.getRange(activeRow, 6).getValue(); //gets the address
var rep = app.getRange(activeRow, 52).getValue(); // gets the rep
var arrived = app.getRange(activeRow, 13).getDisplayValue(); //gets the arrival time
var departed = app.getRange(activeRow, 14).getDisplayValue(); //gets the departed time
var status = app.getRange(activeRow, 45).getDisplayValue(); //gets the pick up status
var type = app.getRange(activeRow,53).getDisplayValue(); //gets the job type

// Condition 1: if sheet is "App"
if (activatedSheetName == "App") {


//Reps

if (rep == "MM") {
var repname = "Mike";
var repEmailAddress = "mmolter@cratersandfreightersnynj.com";}

if (rep == "AG") {
var repname = "Ariel";
var repEmailAddress = "agalayda@cratersandfreightersnynj.com";}

if (rep == "JM") {
var repname = "Joe";
var repEmailAddress = "mmolter@cratersandfreightersnynj.com";}

if (rep == "CH" || rep =="CA") {
var repname = "Christina";
var repEmailAddress = "mmolter@cratersandfreightersnynj.com";}

if (rep == "CK") {
var repname = "Caroline";
var repEmailAddress = "ckopko@cratersandfreightersnynj.com";}

if (rep == "TR") {
var repname = "Tom";
var repEmailAddress = "tom@cratersandfreightersnynj.com";}

if (rep == "RP") {
var repname = "Robert";
var repEmailAddress = "rpoirier@cratersandfreightersnynj.com";}




if (type == "Pick up") {var emailText = "picked up!";}
if (type == "Delivery") {var emailText = "delivered!";}

// Condition 2: if active column is 14 (N)
if (activeColumn == 14) {



// Paste to Check ins

// Condition 3: if the status is "Completed"

if (status == "Completed"){


var inputRow = 1
checkin.insertRowAfter(inputRow);
var jobPaste = checkin.getRange(2,2).setValue(job);
var datePaste = checkin.getRange(2,4).setValue(date);
var repPaste = checkin.getRange(2,3).setValue(rep);


// Paste to Pick up Report
report.insertRowAfter(inputRow);
report.getRange(2,1).setValue(date); // Date
report.getRange(2,2).setValue(job); //Job Number
report.getRange(2,3).setValue(arrived); //Arrived
report.getRange(2,4).setValue(departed); //Departed
report.getRange(2,5).setValue(duration); //Status
report.getRange(2,6).setValue(type); //Type

// this whole section below take photos from the AppSheet folder, searches for the job # in the Shared Company Photos, and either makes a new folder if not existing, or copies them to it
var par_fdr = DriveApp.getFolderById("0B6lqZvelcxkeaWNZMmhKd0JDbjQ"); // Destination folder "Shared Company Photos"
var fdr_name = jobRaw;

try {
var newFdr = par_fdr.getFoldersByName(fdr_name).next();
newFdr.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.EDIT);
}
catch(e) {
var newFdr = par_fdr.createFolder(fdr_name);
newFdr.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.EDIT);
}

var search1 = "title contains ";
var search2 = "'" + jobRaw + "'";
var searchFor= search1+search2;
var fileIds=;
var files = DriveApp.getFolderById("16OkPTUa98pYPrDgJDATzRKTbq5h8_PcX").searchFiles(searchFor); // Source folder "App_Images"
var URL= ;
var link= "https://drive.google.com/uc?export=download&id=";

while (files.hasNext()) {
var file = files.next();

var copyFiles = file.makeCopy(jobRaw+"_on site",newFdr);
var fileId = copyFiles.getId();// To get FileId of the file
fileIds.push(link+fileId+"<P>");

// file.setTrashed(true);
}



var sig = "<p>Thank you,<p><b>The Road Crew<br><font color='#351C75'>Craters & Freighters</font color></b><br>333 Cedar Ave.<br>Middlesex, NJ 08846<br>732-563-9200-Tel<br>732-563-2221-Fax<br>";


var message =
"<font face='tahoma'>Hi "+ repname+","+
"<P>Your job<b> " +job+"</b> has been "+emailText+
"<p>"+contact+
"<br>"+address+
"<p><b>Arrived: </b>" +arrived+
"<br><b>Departed: </b>" +departed+
"<p><b>Time on site: </b>" +duration+
"<div id='pics' style='display: none;'><b>Pictures:</b><p>"+fileIds+
"</div>"+sig;


var bcc1 = "tom@cratersandfreightersnynj.com,mmolter@cratersandfreightersnynj.com,rpoirier@cratersandfreightersnynj.com,kkull@cratersandfreightersnynj.com";
var subject = job;
subject += " "+emailText;
MailApp.sendEmail(repEmailAddress, subject + "", message, {htmlBody: message, name: 'C&F Road Crew', bcc: bcc1});


// end of conditions 1,2,3
}}}

}





Here is the .json file:






{
"timeZone": "America/New_York",
"dependencies": {
"enabledAdvancedServices": [{
"userSymbol": "Drive",
"serviceId": "drive",
"version": "v2"
}, {
"userSymbol": "Calendar",
"serviceId": "calendar",
"version": "v3"
}],
"libraries": [{
"userSymbol": "AddRow",
"libraryId": "164YbqtkyuQe4ObDI-oxi8pY7pvoXxYhJq_J5i51pcxtu0QrdlhHdj11_",
"version": "2"
}]
},
"webapp": {
"access": "ANYONE_ANONYMOUS",
"executeAs": "USER_DEPLOYING"
},
"exceptionLogging": "STACKDRIVER",
"executionApi": {
"access": "ANYONE"
}
}












share|improve this question
















I can not figure out why I keep getting this error when the script trigger runs:



Screen shot of script error



I do not see the Add Row function anywhere in this script however it is in the appscript.json script. Why am I getting this error and can I stop it?



Here is the script that runs on the trigger:






// This script sends an e-mail to the rep when a pick up is complete, stamps the pick up data in the Report tab, and adds the job to the Check In tab

function pickUpEmail() {

var ss = SpreadsheetApp.getActiveSpreadsheet(); // gets active spreadsheet
var checkin = ss.getSheetByName("Check In"); //gets the Check In tab
var app = ss.getSheetByName("App"); /// gets the App tab
var report = ss.getSheetByName("Report"); //gets the Report tab
var activatedSheetName = ss.getActiveSheet().getName();
var activeCell = app.getActiveCell(); //gets the active cell
var activeRow = activeCell.getRow(); //gets the row of the active cell
var activeColumn = activeCell.getColumn(); //gets the column of the active cell
var job = app.getRange(activeRow, 1).getValue(); //gets the job #
var jobRaw = app.getRange(activeRow,49).getDisplayValue(); //gets the raw job # (no EWR- prefix)
var duration = app.getRange(activeRow,50).getDisplayValue() //gets the duration
var date = app.getRange(activeRow, 3).getValue(); //gets the pick up date
var contact = app.getRange(activeRow, 5).getValue(); //gets the contact
var address = app.getRange(activeRow, 6).getValue(); //gets the address
var rep = app.getRange(activeRow, 52).getValue(); // gets the rep
var arrived = app.getRange(activeRow, 13).getDisplayValue(); //gets the arrival time
var departed = app.getRange(activeRow, 14).getDisplayValue(); //gets the departed time
var status = app.getRange(activeRow, 45).getDisplayValue(); //gets the pick up status
var type = app.getRange(activeRow,53).getDisplayValue(); //gets the job type

// Condition 1: if sheet is "App"
if (activatedSheetName == "App") {


//Reps

if (rep == "MM") {
var repname = "Mike";
var repEmailAddress = "mmolter@cratersandfreightersnynj.com";}

if (rep == "AG") {
var repname = "Ariel";
var repEmailAddress = "agalayda@cratersandfreightersnynj.com";}

if (rep == "JM") {
var repname = "Joe";
var repEmailAddress = "mmolter@cratersandfreightersnynj.com";}

if (rep == "CH" || rep =="CA") {
var repname = "Christina";
var repEmailAddress = "mmolter@cratersandfreightersnynj.com";}

if (rep == "CK") {
var repname = "Caroline";
var repEmailAddress = "ckopko@cratersandfreightersnynj.com";}

if (rep == "TR") {
var repname = "Tom";
var repEmailAddress = "tom@cratersandfreightersnynj.com";}

if (rep == "RP") {
var repname = "Robert";
var repEmailAddress = "rpoirier@cratersandfreightersnynj.com";}




if (type == "Pick up") {var emailText = "picked up!";}
if (type == "Delivery") {var emailText = "delivered!";}

// Condition 2: if active column is 14 (N)
if (activeColumn == 14) {



// Paste to Check ins

// Condition 3: if the status is "Completed"

if (status == "Completed"){


var inputRow = 1
checkin.insertRowAfter(inputRow);
var jobPaste = checkin.getRange(2,2).setValue(job);
var datePaste = checkin.getRange(2,4).setValue(date);
var repPaste = checkin.getRange(2,3).setValue(rep);


// Paste to Pick up Report
report.insertRowAfter(inputRow);
report.getRange(2,1).setValue(date); // Date
report.getRange(2,2).setValue(job); //Job Number
report.getRange(2,3).setValue(arrived); //Arrived
report.getRange(2,4).setValue(departed); //Departed
report.getRange(2,5).setValue(duration); //Status
report.getRange(2,6).setValue(type); //Type

// this whole section below take photos from the AppSheet folder, searches for the job # in the Shared Company Photos, and either makes a new folder if not existing, or copies them to it
var par_fdr = DriveApp.getFolderById("0B6lqZvelcxkeaWNZMmhKd0JDbjQ"); // Destination folder "Shared Company Photos"
var fdr_name = jobRaw;

try {
var newFdr = par_fdr.getFoldersByName(fdr_name).next();
newFdr.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.EDIT);
}
catch(e) {
var newFdr = par_fdr.createFolder(fdr_name);
newFdr.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.EDIT);
}

var search1 = "title contains ";
var search2 = "'" + jobRaw + "'";
var searchFor= search1+search2;
var fileIds=;
var files = DriveApp.getFolderById("16OkPTUa98pYPrDgJDATzRKTbq5h8_PcX").searchFiles(searchFor); // Source folder "App_Images"
var URL= ;
var link= "https://drive.google.com/uc?export=download&id=";

while (files.hasNext()) {
var file = files.next();

var copyFiles = file.makeCopy(jobRaw+"_on site",newFdr);
var fileId = copyFiles.getId();// To get FileId of the file
fileIds.push(link+fileId+"<P>");

// file.setTrashed(true);
}



var sig = "<p>Thank you,<p><b>The Road Crew<br><font color='#351C75'>Craters & Freighters</font color></b><br>333 Cedar Ave.<br>Middlesex, NJ 08846<br>732-563-9200-Tel<br>732-563-2221-Fax<br>";


var message =
"<font face='tahoma'>Hi "+ repname+","+
"<P>Your job<b> " +job+"</b> has been "+emailText+
"<p>"+contact+
"<br>"+address+
"<p><b>Arrived: </b>" +arrived+
"<br><b>Departed: </b>" +departed+
"<p><b>Time on site: </b>" +duration+
"<div id='pics' style='display: none;'><b>Pictures:</b><p>"+fileIds+
"</div>"+sig;


var bcc1 = "tom@cratersandfreightersnynj.com,mmolter@cratersandfreightersnynj.com,rpoirier@cratersandfreightersnynj.com,kkull@cratersandfreightersnynj.com";
var subject = job;
subject += " "+emailText;
MailApp.sendEmail(repEmailAddress, subject + "", message, {htmlBody: message, name: 'C&F Road Crew', bcc: bcc1});


// end of conditions 1,2,3
}}}

}





Here is the .json file:






{
"timeZone": "America/New_York",
"dependencies": {
"enabledAdvancedServices": [{
"userSymbol": "Drive",
"serviceId": "drive",
"version": "v2"
}, {
"userSymbol": "Calendar",
"serviceId": "calendar",
"version": "v3"
}],
"libraries": [{
"userSymbol": "AddRow",
"libraryId": "164YbqtkyuQe4ObDI-oxi8pY7pvoXxYhJq_J5i51pcxtu0QrdlhHdj11_",
"version": "2"
}]
},
"webapp": {
"access": "ANYONE_ANONYMOUS",
"executeAs": "USER_DEPLOYING"
},
"exceptionLogging": "STACKDRIVER",
"executionApi": {
"access": "ANYONE"
}
}








// This script sends an e-mail to the rep when a pick up is complete, stamps the pick up data in the Report tab, and adds the job to the Check In tab

function pickUpEmail() {

var ss = SpreadsheetApp.getActiveSpreadsheet(); // gets active spreadsheet
var checkin = ss.getSheetByName("Check In"); //gets the Check In tab
var app = ss.getSheetByName("App"); /// gets the App tab
var report = ss.getSheetByName("Report"); //gets the Report tab
var activatedSheetName = ss.getActiveSheet().getName();
var activeCell = app.getActiveCell(); //gets the active cell
var activeRow = activeCell.getRow(); //gets the row of the active cell
var activeColumn = activeCell.getColumn(); //gets the column of the active cell
var job = app.getRange(activeRow, 1).getValue(); //gets the job #
var jobRaw = app.getRange(activeRow,49).getDisplayValue(); //gets the raw job # (no EWR- prefix)
var duration = app.getRange(activeRow,50).getDisplayValue() //gets the duration
var date = app.getRange(activeRow, 3).getValue(); //gets the pick up date
var contact = app.getRange(activeRow, 5).getValue(); //gets the contact
var address = app.getRange(activeRow, 6).getValue(); //gets the address
var rep = app.getRange(activeRow, 52).getValue(); // gets the rep
var arrived = app.getRange(activeRow, 13).getDisplayValue(); //gets the arrival time
var departed = app.getRange(activeRow, 14).getDisplayValue(); //gets the departed time
var status = app.getRange(activeRow, 45).getDisplayValue(); //gets the pick up status
var type = app.getRange(activeRow,53).getDisplayValue(); //gets the job type

// Condition 1: if sheet is "App"
if (activatedSheetName == "App") {


//Reps

if (rep == "MM") {
var repname = "Mike";
var repEmailAddress = "mmolter@cratersandfreightersnynj.com";}

if (rep == "AG") {
var repname = "Ariel";
var repEmailAddress = "agalayda@cratersandfreightersnynj.com";}

if (rep == "JM") {
var repname = "Joe";
var repEmailAddress = "mmolter@cratersandfreightersnynj.com";}

if (rep == "CH" || rep =="CA") {
var repname = "Christina";
var repEmailAddress = "mmolter@cratersandfreightersnynj.com";}

if (rep == "CK") {
var repname = "Caroline";
var repEmailAddress = "ckopko@cratersandfreightersnynj.com";}

if (rep == "TR") {
var repname = "Tom";
var repEmailAddress = "tom@cratersandfreightersnynj.com";}

if (rep == "RP") {
var repname = "Robert";
var repEmailAddress = "rpoirier@cratersandfreightersnynj.com";}




if (type == "Pick up") {var emailText = "picked up!";}
if (type == "Delivery") {var emailText = "delivered!";}

// Condition 2: if active column is 14 (N)
if (activeColumn == 14) {



// Paste to Check ins

// Condition 3: if the status is "Completed"

if (status == "Completed"){


var inputRow = 1
checkin.insertRowAfter(inputRow);
var jobPaste = checkin.getRange(2,2).setValue(job);
var datePaste = checkin.getRange(2,4).setValue(date);
var repPaste = checkin.getRange(2,3).setValue(rep);


// Paste to Pick up Report
report.insertRowAfter(inputRow);
report.getRange(2,1).setValue(date); // Date
report.getRange(2,2).setValue(job); //Job Number
report.getRange(2,3).setValue(arrived); //Arrived
report.getRange(2,4).setValue(departed); //Departed
report.getRange(2,5).setValue(duration); //Status
report.getRange(2,6).setValue(type); //Type

// this whole section below take photos from the AppSheet folder, searches for the job # in the Shared Company Photos, and either makes a new folder if not existing, or copies them to it
var par_fdr = DriveApp.getFolderById("0B6lqZvelcxkeaWNZMmhKd0JDbjQ"); // Destination folder "Shared Company Photos"
var fdr_name = jobRaw;

try {
var newFdr = par_fdr.getFoldersByName(fdr_name).next();
newFdr.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.EDIT);
}
catch(e) {
var newFdr = par_fdr.createFolder(fdr_name);
newFdr.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.EDIT);
}

var search1 = "title contains ";
var search2 = "'" + jobRaw + "'";
var searchFor= search1+search2;
var fileIds=;
var files = DriveApp.getFolderById("16OkPTUa98pYPrDgJDATzRKTbq5h8_PcX").searchFiles(searchFor); // Source folder "App_Images"
var URL= ;
var link= "https://drive.google.com/uc?export=download&id=";

while (files.hasNext()) {
var file = files.next();

var copyFiles = file.makeCopy(jobRaw+"_on site",newFdr);
var fileId = copyFiles.getId();// To get FileId of the file
fileIds.push(link+fileId+"<P>");

// file.setTrashed(true);
}



var sig = "<p>Thank you,<p><b>The Road Crew<br><font color='#351C75'>Craters & Freighters</font color></b><br>333 Cedar Ave.<br>Middlesex, NJ 08846<br>732-563-9200-Tel<br>732-563-2221-Fax<br>";


var message =
"<font face='tahoma'>Hi "+ repname+","+
"<P>Your job<b> " +job+"</b> has been "+emailText+
"<p>"+contact+
"<br>"+address+
"<p><b>Arrived: </b>" +arrived+
"<br><b>Departed: </b>" +departed+
"<p><b>Time on site: </b>" +duration+
"<div id='pics' style='display: none;'><b>Pictures:</b><p>"+fileIds+
"</div>"+sig;


var bcc1 = "tom@cratersandfreightersnynj.com,mmolter@cratersandfreightersnynj.com,rpoirier@cratersandfreightersnynj.com,kkull@cratersandfreightersnynj.com";
var subject = job;
subject += " "+emailText;
MailApp.sendEmail(repEmailAddress, subject + "", message, {htmlBody: message, name: 'C&F Road Crew', bcc: bcc1});


// end of conditions 1,2,3
}}}

}





// This script sends an e-mail to the rep when a pick up is complete, stamps the pick up data in the Report tab, and adds the job to the Check In tab

function pickUpEmail() {

var ss = SpreadsheetApp.getActiveSpreadsheet(); // gets active spreadsheet
var checkin = ss.getSheetByName("Check In"); //gets the Check In tab
var app = ss.getSheetByName("App"); /// gets the App tab
var report = ss.getSheetByName("Report"); //gets the Report tab
var activatedSheetName = ss.getActiveSheet().getName();
var activeCell = app.getActiveCell(); //gets the active cell
var activeRow = activeCell.getRow(); //gets the row of the active cell
var activeColumn = activeCell.getColumn(); //gets the column of the active cell
var job = app.getRange(activeRow, 1).getValue(); //gets the job #
var jobRaw = app.getRange(activeRow,49).getDisplayValue(); //gets the raw job # (no EWR- prefix)
var duration = app.getRange(activeRow,50).getDisplayValue() //gets the duration
var date = app.getRange(activeRow, 3).getValue(); //gets the pick up date
var contact = app.getRange(activeRow, 5).getValue(); //gets the contact
var address = app.getRange(activeRow, 6).getValue(); //gets the address
var rep = app.getRange(activeRow, 52).getValue(); // gets the rep
var arrived = app.getRange(activeRow, 13).getDisplayValue(); //gets the arrival time
var departed = app.getRange(activeRow, 14).getDisplayValue(); //gets the departed time
var status = app.getRange(activeRow, 45).getDisplayValue(); //gets the pick up status
var type = app.getRange(activeRow,53).getDisplayValue(); //gets the job type

// Condition 1: if sheet is "App"
if (activatedSheetName == "App") {


//Reps

if (rep == "MM") {
var repname = "Mike";
var repEmailAddress = "mmolter@cratersandfreightersnynj.com";}

if (rep == "AG") {
var repname = "Ariel";
var repEmailAddress = "agalayda@cratersandfreightersnynj.com";}

if (rep == "JM") {
var repname = "Joe";
var repEmailAddress = "mmolter@cratersandfreightersnynj.com";}

if (rep == "CH" || rep =="CA") {
var repname = "Christina";
var repEmailAddress = "mmolter@cratersandfreightersnynj.com";}

if (rep == "CK") {
var repname = "Caroline";
var repEmailAddress = "ckopko@cratersandfreightersnynj.com";}

if (rep == "TR") {
var repname = "Tom";
var repEmailAddress = "tom@cratersandfreightersnynj.com";}

if (rep == "RP") {
var repname = "Robert";
var repEmailAddress = "rpoirier@cratersandfreightersnynj.com";}




if (type == "Pick up") {var emailText = "picked up!";}
if (type == "Delivery") {var emailText = "delivered!";}

// Condition 2: if active column is 14 (N)
if (activeColumn == 14) {



// Paste to Check ins

// Condition 3: if the status is "Completed"

if (status == "Completed"){


var inputRow = 1
checkin.insertRowAfter(inputRow);
var jobPaste = checkin.getRange(2,2).setValue(job);
var datePaste = checkin.getRange(2,4).setValue(date);
var repPaste = checkin.getRange(2,3).setValue(rep);


// Paste to Pick up Report
report.insertRowAfter(inputRow);
report.getRange(2,1).setValue(date); // Date
report.getRange(2,2).setValue(job); //Job Number
report.getRange(2,3).setValue(arrived); //Arrived
report.getRange(2,4).setValue(departed); //Departed
report.getRange(2,5).setValue(duration); //Status
report.getRange(2,6).setValue(type); //Type

// this whole section below take photos from the AppSheet folder, searches for the job # in the Shared Company Photos, and either makes a new folder if not existing, or copies them to it
var par_fdr = DriveApp.getFolderById("0B6lqZvelcxkeaWNZMmhKd0JDbjQ"); // Destination folder "Shared Company Photos"
var fdr_name = jobRaw;

try {
var newFdr = par_fdr.getFoldersByName(fdr_name).next();
newFdr.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.EDIT);
}
catch(e) {
var newFdr = par_fdr.createFolder(fdr_name);
newFdr.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.EDIT);
}

var search1 = "title contains ";
var search2 = "'" + jobRaw + "'";
var searchFor= search1+search2;
var fileIds=;
var files = DriveApp.getFolderById("16OkPTUa98pYPrDgJDATzRKTbq5h8_PcX").searchFiles(searchFor); // Source folder "App_Images"
var URL= ;
var link= "https://drive.google.com/uc?export=download&id=";

while (files.hasNext()) {
var file = files.next();

var copyFiles = file.makeCopy(jobRaw+"_on site",newFdr);
var fileId = copyFiles.getId();// To get FileId of the file
fileIds.push(link+fileId+"<P>");

// file.setTrashed(true);
}



var sig = "<p>Thank you,<p><b>The Road Crew<br><font color='#351C75'>Craters & Freighters</font color></b><br>333 Cedar Ave.<br>Middlesex, NJ 08846<br>732-563-9200-Tel<br>732-563-2221-Fax<br>";


var message =
"<font face='tahoma'>Hi "+ repname+","+
"<P>Your job<b> " +job+"</b> has been "+emailText+
"<p>"+contact+
"<br>"+address+
"<p><b>Arrived: </b>" +arrived+
"<br><b>Departed: </b>" +departed+
"<p><b>Time on site: </b>" +duration+
"<div id='pics' style='display: none;'><b>Pictures:</b><p>"+fileIds+
"</div>"+sig;


var bcc1 = "tom@cratersandfreightersnynj.com,mmolter@cratersandfreightersnynj.com,rpoirier@cratersandfreightersnynj.com,kkull@cratersandfreightersnynj.com";
var subject = job;
subject += " "+emailText;
MailApp.sendEmail(repEmailAddress, subject + "", message, {htmlBody: message, name: 'C&F Road Crew', bcc: bcc1});


// end of conditions 1,2,3
}}}

}





{
"timeZone": "America/New_York",
"dependencies": {
"enabledAdvancedServices": [{
"userSymbol": "Drive",
"serviceId": "drive",
"version": "v2"
}, {
"userSymbol": "Calendar",
"serviceId": "calendar",
"version": "v3"
}],
"libraries": [{
"userSymbol": "AddRow",
"libraryId": "164YbqtkyuQe4ObDI-oxi8pY7pvoXxYhJq_J5i51pcxtu0QrdlhHdj11_",
"version": "2"
}]
},
"webapp": {
"access": "ANYONE_ANONYMOUS",
"executeAs": "USER_DEPLOYING"
},
"exceptionLogging": "STACKDRIVER",
"executionApi": {
"access": "ANYONE"
}
}





{
"timeZone": "America/New_York",
"dependencies": {
"enabledAdvancedServices": [{
"userSymbol": "Drive",
"serviceId": "drive",
"version": "v2"
}, {
"userSymbol": "Calendar",
"serviceId": "calendar",
"version": "v3"
}],
"libraries": [{
"userSymbol": "AddRow",
"libraryId": "164YbqtkyuQe4ObDI-oxi8pY7pvoXxYhJq_J5i51pcxtu0QrdlhHdj11_",
"version": "2"
}]
},
"webapp": {
"access": "ANYONE_ANONYMOUS",
"executeAs": "USER_DEPLOYING"
},
"exceptionLogging": "STACKDRIVER",
"executionApi": {
"access": "ANYONE"
}
}






google-apps-script triggers






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 27 '18 at 14:04







Robert P

















asked Nov 26 '18 at 1:23









Robert PRobert P

12




12








  • 3





    please edit your question and include a minimal example. there is not enough information here to recreate the issue

    – DaImTo
    Nov 26 '18 at 1:27











  • There are several kinds of triggers. What kind of trigger is your question about?

    – Rubén
    Nov 26 '18 at 2:02











  • I re-posted the question with supporting scripts sorry if it is too much to post

    – Robert P
    Nov 27 '18 at 14:33











  • "Add Row" is the name of the Script project, not the name of a function. Which one is the code line 7 of checkInEmail file?

    – Rubén
    Nov 27 '18 at 21:16











  • That 's just it, I can not find a Script Project Add Row. Line 7 in the checkinemail script is var checkin = ss.getSheetByName("Check In"), //gets the Check In tab

    – Robert P
    Nov 28 '18 at 23:25














  • 3





    please edit your question and include a minimal example. there is not enough information here to recreate the issue

    – DaImTo
    Nov 26 '18 at 1:27











  • There are several kinds of triggers. What kind of trigger is your question about?

    – Rubén
    Nov 26 '18 at 2:02











  • I re-posted the question with supporting scripts sorry if it is too much to post

    – Robert P
    Nov 27 '18 at 14:33











  • "Add Row" is the name of the Script project, not the name of a function. Which one is the code line 7 of checkInEmail file?

    – Rubén
    Nov 27 '18 at 21:16











  • That 's just it, I can not find a Script Project Add Row. Line 7 in the checkinemail script is var checkin = ss.getSheetByName("Check In"), //gets the Check In tab

    – Robert P
    Nov 28 '18 at 23:25








3




3





please edit your question and include a minimal example. there is not enough information here to recreate the issue

– DaImTo
Nov 26 '18 at 1:27





please edit your question and include a minimal example. there is not enough information here to recreate the issue

– DaImTo
Nov 26 '18 at 1:27













There are several kinds of triggers. What kind of trigger is your question about?

– Rubén
Nov 26 '18 at 2:02





There are several kinds of triggers. What kind of trigger is your question about?

– Rubén
Nov 26 '18 at 2:02













I re-posted the question with supporting scripts sorry if it is too much to post

– Robert P
Nov 27 '18 at 14:33





I re-posted the question with supporting scripts sorry if it is too much to post

– Robert P
Nov 27 '18 at 14:33













"Add Row" is the name of the Script project, not the name of a function. Which one is the code line 7 of checkInEmail file?

– Rubén
Nov 27 '18 at 21:16





"Add Row" is the name of the Script project, not the name of a function. Which one is the code line 7 of checkInEmail file?

– Rubén
Nov 27 '18 at 21:16













That 's just it, I can not find a Script Project Add Row. Line 7 in the checkinemail script is var checkin = ss.getSheetByName("Check In"), //gets the Check In tab

– Robert P
Nov 28 '18 at 23:25





That 's just it, I can not find a Script Project Add Row. Line 7 in the checkinemail script is var checkin = ss.getSheetByName("Check In"), //gets the Check In tab

– Robert P
Nov 28 '18 at 23:25












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53473665%2fcell-reference-out-of-range-summary-of-failures-for-google-apps-script-add-row%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53473665%2fcell-reference-out-of-range-summary-of-failures-for-google-apps-script-add-row%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks