I have a script that works perfectly but I have some staff that will run the script even if a cell is red which was put in place to prevent missing data being sent out.
Is there a way I can add a line in my current script so it wont run if there is a red cell present?
I have looked at various suggestions but not sure on how to add the line into my current script that works perfect for what we need.
My situation:
I have a script that works perfectly but I have some staff that will run the script even if a cell is red which was put in place to prevent missing data being sent out.
Is there a way I can add a line in my current script so it wont run if there is a red cell present? Thank you in advance. 🙂
Current Script is:
function Email8() {
var ssID = SpreadsheetApp.getActiveSpreadsheet().getId();
var sheetName = SpreadsheetApp.getActiveSpreadsheet().getName();
//var email = Session.getUser().getEmail();
var emailRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("S/A - Darrin").getRange("G9:H10");
var emailAddress = emailRange.getValue();
var subject = "S/A - Darrin";
var body = ("Thank you for your business.");
var requestData = {"method": "GET", "headers":{"Authorization":"Bearer "+ScriptApp.getOAuthToken()}};
var shID = getSheetID("S/A - Darrin") //Get Sheet ID of sheet name "Master"
var url = "https://docs.google.com/spreadsheets/d/"+ ssID + "/export?format=pdf&id="+ssID+"&gid="+shID;
var result = UrlFetchApp.fetch(url , requestData);
var contents = result.getContent();
var bcc = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("S/A - Darrin").getRange("F5:G8").getDisplayValues().flat().join(",");var filename = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("S/A - Darrin").getRange("A21").getDisplayValue();
MailApp.sendEmail(emailAddress, subject, body, { attachments: [result.getBlob().setName(`${filename}.pdf`)], bcc });
var ssID = SpreadsheetApp.getActiveSpreadsheet().getId();
var sheetName = SpreadsheetApp.getActiveSpreadsheet().getName();
//var email = Session.getUser().getEmail();
var email_ID1 = "[email protected]";
var subject = "CTC Sales Agreement.";
var body = ("Attached is your document. n Thank you for your business");
var requestData = {"method": "GET", "headers":{"Authorization":"Bearer "+ScriptApp.getOAuthToken()}};
var shID = getSheetID("Xero Invoice - Darrin") //Get Sheet ID of sheet name "Xero Invoice - Darrin"
var url = "https://docs.google.com/spreadsheets/d/"+ ssID + "/export?format=csv&id="+ssID+"&gid="+shID;
var result = UrlFetchApp.fetch(url , requestData);
var contents = result.getContent();
MailApp.sendEmail (email_ID1, subject ,body, {attachments:[{fileName:sheetName+".csv", content:contents, mimeType:"application//csv"}]});
};
function getSheetID(name){
var ss = SpreadsheetApp.getActive().getSheetByName(name)
var sheetID = ss.getSheetId().toString()
return sheetID
}