Send an email with a calculated value present in sheet “PROVA” when a line of a FORM is filled out

16 views
Skip to first unread message

Simone Prove

unread,
Jun 8, 2023, 3:02:02 AM6/8/23
to Google Apps Script Community

Send an email with a calculated value present in sheet “PROVA” when a line of a FORM is filled out

 

Good morning, I created a Form "Modulo 1", and the results of the form are written in a sheet of Google sheet “PROVA".

I would like to make sure that for each row created in "PROVA", and therefore every time the results of a form are sent in a "PROVA" row, an email, ONLY the last row, is sent to the email address present in the newly created row.

Also, Could you help me to make sure that a total is calculated in each row, in column "H" and that it is included in the email to be sent?

In column "H" (in the case of row 3) the formula is as follows: "=(D3*Calculations!$B$2)+(E3*Calculations!$B$3)"

 

I used this code (found on the internet):

function sendMailEdit(e){

 

 if (e.range.columnStart != 5 || e.value == "") return;

 const rData = e.source.getActiveSheet().getRange(e.range.rowStart,1,1,4).getValues();

 

 let itemsOrdered = rData[0][0];

 let email = rData[0][1];

 let name = rData[0][2];

 let trackingNo = rData[0][3];

 let importo = rData[0][7];

 

 let msg = "Salve, " + name + ". il tuo ordine: " + itemsOrdered + " sarà pronto. " + trackingNo + " Totale: " + importo +". Cordiali saluti"

 

 MailApp.sendEmail(email, "Shipped Order", msg)

}

 

 but it sends the email every time the value of column "E" is different from "blank", but it doesn't point to the last row created by form “Modulo 1” and it doesn't automatically create the formula in "H3".

Thank you very much.


I attach the image of the sheet PROVA

Example.jpg
Reply all
Reply to author
Forward
0 new messages