Miyer
Miyer

Reputation: 365

Display Value on Edit

This code triggers an email of a new price value in column 14 onEdit, but it doesn't give the display value on the sheet. E.g. 15,00,000 is the format in the sheet but it generates the email as 1500000. where did I go wrong in the below code?

function sendEmail(e) {
    var thisSheet = e.source.getActiveSheet(),
        cols = [14],
        ind = cols.indexOf(e.range.columnStart);
    if (thisSheet.getName() !== 'SheetPrice' || ind == -1) return;
    var headers = thisSheet.getRange(1, 1, 1, 6).getValues()[0],
        thisRow = thisSheet.getRange(e.range.rowStart, 1, 1, 6).getDisplayValues()[0],
        vehicle = thisRow[3],
        vehicle2 = thisRow[4],
        body = "",
        i = 0; 
   while (i < 6) {
        body += headers[i] + '- ' + thisRow[i] + '\n';
        i++;
    }
if (ind == 0 && e.value) {
       var recipients = "[email protected]",
           subject = "⚫ Price updated ► " +vehicle +" "+vehicle2
           body += "New Price ► "+ e.value + "\n\nabc limited" ;
   }
   MailApp.sendEmail(recipients, subject,  body, {name: "abc limited"});
}

Upvotes: 0

Views: 141

Answers (1)

Cooper
Cooper

Reputation: 64100

body += "New Price ► "+ thisSheet.getRange(e.range.rowStart,e.range.columnStart).getDisplayValue() + "\n\nabc limited" ;

Upvotes: 1

Related Questions