I am trying to create an alert based on the answer on the prompt, prompt is working but it does not show the pop up alert message after answering the prompt. Here is my script hoping someone can help please
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.prompt('Please provide your shift on the box below.', ui.ButtonSet.OK);
if (result == "morning") {
alert("We have " + Sheet17.D3 + " OT hours for TLs and " + Sheet17.D11 + " for QAs!");
}
if (result == "dawn") {
alert("We have " + Sheet17.D2 + " OT hours for TLs and " + Sheet17.D10 + " for QAs!");
}
if (result == "EM") {
alert("We have " + Sheet17.D4 + " OT hours for TLs and " + Sheet17.D12 + " for QAs!");
}
if (result == "Mid") {
alert("We have " + Sheet17.D5 + " OT hours for TLs and " + Sheet17.D13 + " for QAs!");
}
if (result == "evening") {
alert("We have " + Sheet17.D6 + " OT hours for TLs and " + Sheet17.D14 + " for QAs!");
}
if (result == "night") {
alert("We have " + Sheet17.D7 + " OT hours for TLs and " + Sheet17.D15 + " for QAs!");
}
}
Tried different scripts but still not working
The script has several problems
It's using a reserved function name that will cause that the script run every time that the spreadsheet is opened. It might work for the spreadsheet owner but it will not work for spreadsheet editors because restrictions introduced by Google several years ago that prevent that a simple on open trigger opens a user interface element.
The variable result has not being declared.
The variable Sheet17 has not being declared.
The variable alert has not being declared.
The following function shows how to use Ui.prompt
function myFunction(){
const ui = SpreadsheetApp.getUi();
const response = ui.prompt('Please provide your shift on the box below.', ui.ButtonSet.OK);
if(response.getResponseText() === 'morning'){
ui.alert('Morning message')
}
}
Note: The code should be added on a script bounded to a spreadsheet.
To learn about how to get values from a spreadsheet please read https://developers.google.com/apps-script/guides/sheets
References
https://developers.google.com/apps-script/reference/base/prompt-response
Try it this way:
function onMyOpen() {
const ui = SpreadsheetApp.getUi();
const result = ui.prompt('Please provide your shift on the box below.', ui.ButtonSet.OK).getResponseText();
const ss = SpreadsheetApp.getActive();
const sh17 = ss.getSheetByName("Sheet17");
const [D2,D3,D4,D5,D6,D7] = sh17.getRange("D2:D7").getValues().flat();
const [D10,D11,D12,D13,D14,D15] = sh17.getRange("D10:D15").getValues().flat();
if (result == "morning") {
alert("We have " + D3 + " OT hours for TLs and " + D11 + " for QAs!");
}
if (result == "dawn") {
alert("We have " + D2 + " OT hours for TLs and " + D10 + " for QAs!");
}
if (result == "EM") {
alert("We have " + D4 + " OT hours for TLs and " + D12 + " for QAs!");
}
if (result == "Mid") {
alert("We have " + D5 + " OT hours for TLs and " + D13 + " for QAs!");
}
if (result == "evening") {
alert("We have " + D6 + " OT hours for TLs and " + D14 + " for QAs!");
}
if (result == "night") {
alert("We have " + D7 + " OT hours for TLs and " + D15 + " for QAs!");
}
}
Run the following function to create installable trigger
function createOnMyOpenTrigger() {
if(ScriptApp.getProjectTriggers().filter(t => t.getHandlerFunction() == "onMyOpen").length == 0) {
ScriptApp.newTrigger("onMyOpen").forSpreadsheet(ss).onOpen().create();
}
}
Related
Hello guys! Could you please help me out? I am trying to use certain conditions but they seem to be ignored for some reasons. When I ran the code the popped-up random number given was 93 that fitted in the first declared statement (if), but, It got ignored and moved to the last statement even when true && true.
I do not understand why...
???
function loveMatching (name1, name2) {
name1 = prompt ("Enter your name!");
name2 = prompt ("Enter your crush name!");
if (matchingPercentage() >= 70 && matchingPercentage() <=100) {
document.write(" The compability between: " + name1 + " and " + name2 + " is of a " + matchingPercentage() + "%. You guys are meant to be together!");
}
else if( matchingPercentage() >=30 && matchingPercentage() <70) {
document.write(" The compability between: " + name1 + " and " + name2 + " is of a " + matchingPercentage() + "%. Too close to fail!");
}
else {
document.write(" The compability between: " + name1 + " and " + name2 + " is of a " + matchingPercentage() + "%. You better look in another direction!");
}
}
function matchingPercentage() {
var n = Math.random();
var n = Math.floor(n * 100) + 1;
return n;
}
loveMatching();
you're calculating a new match % everytime you check it, multiple times in the same conditional. you need to just do it once at the start:
function loveMatching (name1, name2) {
name1 = prompt ("Enter your name!");
name2 = prompt ("Enter your crush name!");
const matchPercent = matchingPercentage(); // call one time
if (matchPercent >= 70 && matchPercent <=100) {
document.write(" The compability between: " + name1 + " and " + name2 + " is of a " + matchPercent + "%. You guys are meant to be together!");
}
else if( matchPercent >=30 && matchPercent <70) {
document.write(" The compability between: " + name1 + " and " + name2 + " is of a " + matchPercent + "%. Too close to fail!");
}
else {
document.write(" The compability between: " + name1 + " and " + name2 + " is of a " + matchPercent + "%. You better look in another direction!");
}
}
i need to make a dice rolling program that rolls dice and says who won if it is a tie it rolls again and after each win you earn a point first to 5 wins the game whenever i run mine it uses the same numbers over and over again because it only generated the once how can i fix this and what else do i need to do after this issue to finish the program, thanks for the help!
<script>
var comp1 = Math.floor((Math.random()*6) + 1);
var comp2 = Math.floor((Math.random()*6) + 1);
var you1 = Math.floor((Math.random()*6) + 1);
var you2 = Math.floor((Math.random()*6) + 1);
var counter = 1;
var youPoints = 0;
var mePoints = 0;
while(counter < 6)
{{
alert("Let's shake some dice!")
alert("your turn to roll \n\n you shook a " + you1 + " and a " + you2 + ", so you have " + (you1 + you2));
alert("my turn to roll \n\n I shook a " + comp1 + " and a " + comp2 + ", so I have " + (comp1 + comp2));
counter++
var you = you1 + you2;
var me = comp1 + comp2;
if(you > me)
{
alert("you win " + you + " to " + me);
youPoints++
}
if (me > you)
{
alert("I win " + me + " to " + you);
mePoints++
}
}}
</script>
You're initializing your random variables (you1, you2) outside the while loop.
It's being initialized only once and hence producing the same number every time.
Bring it inside the loop, and that might fix it!
Move the code the generates the random numbers to inside of the loop because, right now, they only generate once... before the loop even starts.
Also, do yourself a favor and use a for counting loop, rather than a while, because while loops are easily misconfigured to cause infinite loops to occur.
var youPoints = 0;
var mePoints = 0;
for(var counter = 1; counter < 6; counter++){
// The code that generates the random numbers has to be in the loop
// in order for new randoms to be generated upon each loop iteration
var comp1 = Math.floor((Math.random()*6) + 1);
var comp2 = Math.floor((Math.random()*6) + 1);
var you1 = Math.floor((Math.random()*6) + 1);
var you2 = Math.floor((Math.random()*6) + 1);
alert("Let's shake some dice!")
alert("your turn to roll \n\n you shook a " + you1 + " and a " + you2 + ", so you have " + (you1 + you2));
alert("my turn to roll \n\n I shook a " + comp1 + " and a " + comp2 + ", so I have " + (comp1 + comp2));
var you = you1 + you2;
var me = comp1 + comp2;
// Don't make two separate if statements. Use one with an else if
if(you > me) {
alert("you win " + you + " to " + me);
youPoints++
} else if (me > you) {
alert("I win " + me + " to " + you);
mePoints++
}
}
Here you go, this should be a complete working example.
Note: I replaced alert() for console.log() so we can see the output here in the console and without popups, but it will work either way.
var compPoints = 0;
var youPoints = 0;
var winnerOfFive = false;
function rollTheDice() {
return Math.floor((Math.random()*6) + 1);
}
function rollAllDice() {
let you1 = rollTheDice();
let you2 = rollTheDice();
let comp1 = rollTheDice();
let comp2 = rollTheDice();
console.log("your turn to roll \n\n you shook a " + you1 + " and a " + you2 + ", so you have " + (you1 + you2));
console.log("my turn to roll \n\n I shook a " + comp1 + " and a " + comp2 + ", so I have " + (comp1 + comp2));
var you = you1 + you2;
var me = comp1 + comp2;
if(you > me) {
console.log("you win " + you + " to " + me);
youPoints++;
} else if(me > you) {
console.log("I win " + me + " to " + you);
compPoints++;
} else {
console.log("It was a tie, no one wins. Re-rolling...");
rollAllDice();
}
}
function startGame() {
while( !winnerOfFive ) {
console.log("Let's shake some dice!")
rollAllDice();
if(compPoints == 5) {
console.log("Comp is first to 5 games and wins " + compPoints + " to " + youPoints);
winnerOfFive = true;
} else if (youPoints == 5) {
console.log("You are first to 5 games and win " + youPoints + " to " + compPoints);
winnerOfFive = true;
}
}
}
// Start the game like this
startGame();
Javascript we had for Unified interface of Dynamics 365 to format phone numbers was working perfectly until the latest update, now it only works in custom interface and has stopped working in UI, anybody has any idea how this can be fixed?
var XXX = window.XXX || {};
(function() {
// Code to run in the form OnLoad event
this.formOnLoad = function(executionContext) {
var formContext = executionContext.getFormContext();
// display the form level notification as an INFO
formContext.ui.setFormNotification(message, "INFO", myUniqueId);
// Wait for 5 seconds before clearing the notification
window.setTimeout(function() {
formContext.ui.clearFormNotification(myUniqueId);
}, 5000);
}
// Code to run in the attribute OnChange event
this.mobilePhoneFormatting = function(executionContext) {
var formContext = executionContext.getFormContext();
var mobilePhone = formContext.getAttribute("mobilephone").getValue();
var formatPhone = "";
try {
if (mobilePhone != null) {
var phoneNumbers = mobilePhone.replace(/\D/g, '');
if (phoneNumbers.length == 10) { //10 digit case. Output adds +1 and proper format
formatPhone = ("+1 (" + phoneNumbers.substring(0, 3) + ") " + phoneNumbers.substring(3, 6) + "-" + phoneNumbers.substring(6, 10));
} else if (phoneNumbers.length == 11) { //11 digit case. Output proper format
formatPhone = ("+" + phoneNumbers.substring(0, 1) + " (" + phoneNumbers.substring(1, 4) + ") " + phoneNumbers.substring(4, 7) + "-" + phoneNumbers.substring(7, 11));
} else if (phoneNumbers.length == 14) { //14 digit case. Without Country code and with extension
formatPhone = ("+1 (" + phoneNumbers.substring(0, 3) + ") " + phoneNumbers.substring(3, 6) + "-" + phoneNumbers.substring(6, 10) + " x" + phoneNumbers.substring(10, 14));
} else if (phoneNumbers.length == 15) { //15 digit case. With Country code and extension
formatPhone = ("+" + phoneNumbers.substring(0, 1) + " (" + phoneNumbers.substring(1, 4) + ") " + phoneNumbers.substring(4, 7) + "-" + phoneNumbers.substring(7, 11) + " x" + phoneNumbers.substring(11, 15));
} else if (phoneNumbers.length == 4) { //4 digit case. Extension Only
formatPhone = ("x" + phoneNumbers.substring(0, 4));
} else {
formatPhone = mobilePhone;
}
formContext.getAttribute("mobilephone").setValue(formatPhone);
formContext.data.entity.save();
}
} catch (err) {
txt = "There was an error formatting the Phone Number.\n\n";
txt += "Error description: " + err.message + "\n\n";
txt += "Click OK to continue.\n\n";
alert(txt);
}
}
// var
var differentBillsInUSD;
// start of bills
differentBillsInUSD = {
firstBill: parseInt(124),
secondBill: parseInt(48),
thirdBill: parseInt(268),
fourthBill: parseInt(180),
fifthBill: parseInt(42),
}
// console to check if everything is alright
console.log(differentBillsInUSD);
console.log("Checking if bill is alright ^");
function calcBill(numberBill) {
if (numberBill < 50) {
return(numberBill + " tip is: " (numberBill*0.20));
} else if (numberBill >= 50 && numberBill <= 200) {
return(numberBill + " tip + total is: " (numberBill*0.15));
} else if (numberBill > 200) {
return(numberBill + " tip + total is: " (numberBill*0.20));
}
}
function calcBillTotal(numberBill) {
if (numberBill < 50) {
return(numberBill + " tip + total is: " ((numberBill*0.20)+numberBill));
} else if (numberBill >= 50 && numberBill <= 200) {
return(numberBill + " tip + total is: " ((numberBill*0.15)+numberBill));
} else if (numberBill > 200) {
return(numberBill + " tip + total is: " ((numberBill*0.20)+numberBill));
}
}
// first bill
console.log(calcBill(differentBillsInUSD.firstBill));
console.log(calcBillTotal(differentBillsInUSD.firstBill));
// second bill
cosnole.log(calcBill(differentBillsInUSD.secondBill));
cosnole.log(calcBillTotal(differentBillsInUSD.secondBill));
ERROR CODE
script.js:21 Uncaught TypeError: " tip + total is: " is not a function
at calcBill (script.js:21)
at script.js:37
It won't work because I am doing to a coding challenge.
It also seems that I am new to javascript.
I tried to do my research, it was very difucult to find.
I am in the middle of code but can not fix.
return(numberBill + " tip is: " + (numberBill*0.20));
you just miss to place a plus sign inside...
return(numberBill + " tip + total is: " (numberBill*0.15));
In JS when you place () after anything it tries to execute it as a function. as you missed the "+" just before "(numberBill*0.15)", so its trying to execute " tip + total is: " as a function. You just need to add a "+"
when you are concatenating a string with a variable , you need to use "+" sign in javascript. Here if you noticed in each if ,else if and else statement you are missing "+" sign.
if (numberBill < 50) {
return(numberBill + " tip is: " + (numberBill*0.20));
I have a script that sends e-mails from a google sheet. The data in the sheet is populated with a google form. A few fields in the sheet use array formulas to add additional data to the sheet example: array formulas in the sheet to populate fields:
=ArrayFormula(IF(ROW(A:A)=1,"link",VLOOKUP($C:C,array!$A$2:$C$9000,3,FALSE)))
This causes "#N/A" to show in rows where no user has submitted data. I am ok with that but it is causing the script to take a long time to run. When the user submits data, a timestamp is placed in the first column. Can I use that to get the script to skip to stop if empty? Right now, I have the script checking 1000 rows but ideally it would check rows for timestamp and if no timestamp, stop.
/**
* Add a menu item that calls this script
*/
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menu = [{
name: "Send Email",
functionName: "uiSendEmail"
}];
ss.addMenu("SCCCounseling", menu);
}
var EMAIL_SENT = "EMAIL_SENT";
/**
* Send the e-mail to everyone listed in the spreadsheet
*/
function uiSendEmail() {
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 2; // First row of data to process
var numRows = 1000;
var dataRange = sheet.getRange(startRow, 1, numRows, 1000)
// Fetch values for each row in the Range.
var data = dataRange.getValues();
for (var i = 0; i < data.length; ++i) {
var row = data[i];
var timestamp = row[0];
var username = row[1];
var counselor = row[2];
var date = row[3];
var sName = row[4];
var wNum = row[5];
var toemail = row[6];
var sLName= row[7];
var pin = row[8];
var link = row[9];
var cMail = row[10];
var emailSent = row[11];
var subject = "Online Counseling Appointment Confirmation - " + sName + " " + sLName + " " + wNum + " ";
var emailBody = "Online Counseling Appointment " + " - " + sName + " " + sLName + " " + wNum +
"\n\nHello " + sName +
"\n\n\nYou are scheduled for an online counseling appointment for Sacramento City College: " +
"\n\n\nDate: " + date +
"\n\nPlease follow the instructions below at least one day before your appointment to make " +
"\nsure that your computer is ready. " +
"\n\nIf your computer is not ready, you will not be able to " +
"\nparticipate in online counseling. " +
"\n\nTo cancel your appointment, please email: " +
"\n\nCounselor: " + counselor + " at " + cMail +
"\n\nYou will be required to show photo identification at the start of the appointment to verify " +
"\nyour identity. " +
"\n\n\nONE DAY BEFORE YOUR APPOINTMENT " +
"\n\nGo to the following link to test your computer readiness one day before your " +
"\nscheduled online counseling appointment: " +
"\n\nhttp://www.cccconfer.org/support/supportReadiness.aspx " +
"\n\n\nFIVE MINUTES BEFORE YOUR APPOINTMENT: " +
"\n\nGo to the following link to connect to the online counseling appointment and the " +
"\ncounselor will join you: " + link +
"\n\n\nIf you want to use the phone for audio: " +
"\n\nTelephone Conference Line: 719-785-4469, Toll-free: 1-888-450-4821 " +
"\n\nStudent PIN: " + pin +
"\n\n\nFOR ASSISTANCE CONNECTING" +
"\n\nContact CCC Confer Client Services, Monday - Friday 8am - 4pm " +
"\n\nPhone: 1-760-744-1150 ext 1537 or 1554 " +
"\n\nEmail: clientservices#cccconfer.org " +
"\n\n\nThank you " + sName;
var htmlBody = "<b>Online Counseling Appointment Confirmation" + " -</b> " + " - " + sName + " " + sLName + " " + wNum +
"<br/><br/><br/>" + "Hello " + sName + ", <br/><br/>" + "You are scheduled for an online counseling appointment for Sacramento City College: <i>" +
"<br/><br/><br/>" + "<b>Date: " + date + "<br/><br/>" + "</b><br/>" + "</i><br/>Please follow the instructions below <b>at least one day before</b> your appointment to make sure that your computer is ready." +
"<br/><br/><i>If your computer is not ready, you will not be able to participate in online counseling.</i> " + "<br/><br/> To cancel your appointment, please email: " +
"<br/><br/><font color=\"red\">Counselor:</font> " + counselor + " at " + cMail + "<br/><br/><br/>You will be required to show photo identification at the start of the appointment to verify your identity. " +
"<br/><br/><br/><b>ONE DAY BEFORE YOUR APPOINTMENT:</b> " + "<br/><br/>➢ Go to the following link to test your computer readiness one day before your scheduled online counseling appointment: " +
"<br/><br/>http://www.cccconfer.org/support/supportReadiness.aspx " +
"<br/><br/><br/><b>FIVE MINUTES BEFORE YOUR APPOINTMENT:</b>" +
"<br/><br/>➢ Go to the following link to connect to the online counseling appointment and the counselor will join you (link to counselor online room). " +
"<br/><br/> " + link +
"<br/><br/>➢ If you want to use the phone for audio: " +
"<br/><ul><li>Telephone Conference Line: 719-785-4469, Toll-free: 1-888-450-4821</li><li>Student PIN: " + pin + "</li></ul>" +
"<br/><br/><br/><b>FOR ASSISTANCE CONNECTING</b>" +
"<br/><br/>Contact CCC Confer Client Services, Monday - Friday 8am - 4pm " +
"<br/><br/>Phone: 1-760-744-1150 ext 1537 or 1554 " +
"<br/><br/>Email: clientservices#cccconfer.org " +
"<br/><br/><br/>Thank You! " + sName;
var optAdvancedArgs = {name: "SCC Counseling", htmlBody: htmlBody};
if (emailSent != EMAIL_SENT) { // Prevents sending duplicates
var subject = "Online Counseling Appointment Confirmation - " + sName + " " + wNum + " ";
MailApp.sendEmail(toemail, subject, emailBody, optAdvancedArgs);
sheet.getRange(startRow + i, 12).setValue(EMAIL_SENT);
// Make sure the cell is updated right away in case the script is interrupted
SpreadsheetApp.flush();
}
}
}
Create a simple function to test for #NA!:
function checkForNa() {
var theVal = SpreadsheetApp.getActiveSpreadsheet().getRange("A1").getValue();
if (theVal === "#NA!") {
Logger.log('it's NA');
return;
};
Logger.log('There is data. The code continued');
};
Intentionally cause an #NA! error, and run the code.
If the code works, incorporate the conditional check into your code. The return; statement will stop your code.
If you don't want your code to stop, but to skip this row, a break; statement can be used, but the break; can only be used inside of a loop. So, you'll need a nested loop to check for the #NA! value, to skip over that one line.
function checkForNa() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var startRow = 2; // First row of data to process
var numRows = 1000;
var dataRange = sheet.getRange(startRow, 2, numRows, 1000)
var data = dataRange.getValues();
for (var i = 0; i < data.length; ++i) {
var theVal = data[i][0]; //Get first value out of this row
for (var j = 0;j<1;j++) { //Only loops once
if (theVal === "#NA!") {
Logger.log('skipped this row: ' + i);
break;
};
Logger.log('loop number: ' + i);
};
};
};
This is example code. You'll need to adapt it to your code.
Just create a simple IF statement to check for a timestamp. It will work just fine. You may have to fix closing brackets because I'm not sure where they were supposed to be.
/**
* Add a menu item that calls this script
*/
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menu = [{
name: "Send Email",
functionName: "uiSendEmail"
}];
ss.addMenu("SCCCounseling", menu);
}
var EMAIL_SENT = "EMAIL_SENT";
/**
* Send the e-mail to everyone listed in the spreadsheet
*/
function uiSendEmail() {
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 2; // First row of data to process
var numRows = 1000;
var dataRange = sheet.getRange(startRow, 1, numRows, 1000)
// Fetch values for each row in the Range.
var data = dataRange.getValues();
for (var i = 0; i < data.length; ++i) {
if (data[i][INDEX_OF_TIMESTAMP] != "") {
var row = data[i];
var timestamp = row[0];
var username = row[1];
var counselor = row[2];
var date = row[3];
var sName = row[4];
var wNum = row[5];
var toemail = row[6];
var sLName= row[7];
var pin = row[8];
var link = row[9];
var cMail = row[10];
var emailSent = row[11];
var subject = "Online Counseling Appointment Confirmation - " + sName + " " + sLName + " " + wNum + " ";
var emailBody = "Online Counseling Appointment " + " - " + sName + " " + sLName + " " + wNum +
"\n\nHello " + sName +
"\n\n\nYou are scheduled for an online counseling appointment for Sacramento City College: " +
"\n\n\nDate: " + date +
"\n\nPlease follow the instructions below at least one day before your appointment to make " +
"\nsure that your computer is ready. " +
"\n\nIf your computer is not ready, you will not be able to " +
"\nparticipate in online counseling. " +
"\n\nTo cancel your appointment, please email: " +
"\n\nCounselor: " + counselor + " at " + cMail +
"\n\nYou will be required to show photo identification at the start of the appointment to verify " +
"\nyour identity. " +
"\n\n\nONE DAY BEFORE YOUR APPOINTMENT " +
"\n\nGo to the following link to test your computer readiness one day before your " +
"\nscheduled online counseling appointment: " +
"\n\nhttp://www.cccconfer.org/support/supportReadiness.aspx " +
"\n\n\nFIVE MINUTES BEFORE YOUR APPOINTMENT: " +
"\n\nGo to the following link to connect to the online counseling appointment and the " +
"\ncounselor will join you: " + link +
"\n\n\nIf you want to use the phone for audio: " +
"\n\nTelephone Conference Line: 719-785-4469, Toll-free: 1-888-450-4821 " +
"\n\nStudent PIN: " + pin +
"\n\n\nFOR ASSISTANCE CONNECTING" +
"\n\nContact CCC Confer Client Services, Monday - Friday 8am - 4pm " +
"\n\nPhone: 1-760-744-1150 ext 1537 or 1554 " +
"\n\nEmail: clientservices#cccconfer.org " +
"\n\n\nThank you " + sName;
var htmlBody = "<b>Online Counseling Appointment Confirmation" + " -</b> " + " - " + sName + " " + sLName + " " + wNum +
"<br/><br/><br/>" + "Hello " + sName + ", <br/><br/>" + "You are scheduled for an online counseling appointment for Sacramento City College: <i>" +
"<br/><br/><br/>" + "<b>Date: " + date + "<br/><br/>" + "</b><br/>" + "</i><br/>Please follow the instructions below <b>at least one day before</b> your appointment to make sure that your computer is ready." +
"<br/><br/><i>If your computer is not ready, you will not be able to participate in online counseling.</i> " + "<br/><br/> To cancel your appointment, please email: " +
"<br/><br/><font color=\"red\">Counselor:</font> " + counselor + " at " + cMail + "<br/><br/><br/>You will be required to show photo identification at the start of the appointment to verify your identity. " +
"<br/><br/><br/><b>ONE DAY BEFORE YOUR APPOINTMENT:</b> " + "<br/><br/>➢ Go to the following link to test your computer readiness one day before your scheduled online counseling appointment: " +
"<br/><br/>http://www.cccconfer.org/support/supportReadiness.aspx " +
"<br/><br/><br/><b>FIVE MINUTES BEFORE YOUR APPOINTMENT:</b>" +
"<br/><br/>➢ Go to the following link to connect to the online counseling appointment and the counselor will join you (link to counselor online room). " +
"<br/><br/> " + link +
"<br/><br/>➢ If you want to use the phone for audio: " +
"<br/><ul><li>Telephone Conference Line: 719-785-4469, Toll-free: 1-888-450-4821</li><li>Student PIN: " + pin + "</li></ul>" +
"<br/><br/><br/><b>FOR ASSISTANCE CONNECTING</b>" +
"<br/><br/>Contact CCC Confer Client Services, Monday - Friday 8am - 4pm " +
"<br/><br/>Phone: 1-760-744-1150 ext 1537 or 1554 " +
"<br/><br/>Email: clientservices#cccconfer.org " +
"<br/><br/><br/>Thank You! " + sName;
var optAdvancedArgs = {name: "SCC Counseling", htmlBody: htmlBody};
if (emailSent != EMAIL_SENT) { // Prevents sending duplicates
var subject = "Online Counseling Appointment Confirmation - " + sName + " " + wNum + " ";
MailApp.sendEmail(toemail, subject, emailBody, optAdvancedArgs);
sheet.getRange(startRow + i, 12).setValue(EMAIL_SENT);
// Make sure the cell is updated right away in case the script is interrupted
SpreadsheetApp.flush();
}
}
}
If you know how many rows are usually empty (em), check those rows with r+(em+1). In the example below, I am dealing with:
1 row missing randomly
New rows populated, but column A missing
New rows populated with column A populated
I checked for all 3 conditions in a while loop.
function onRow(e){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var column = ss.getRange('A:I');
var values = column.getValues(); // get all data in one call
var r = 0;
while ( (values[r] && values[r][1] != "") || (values[r] && values[r][2] != "" ) || (values[r+2] && values[r+2][2] != "" )) {
r++;
}