0

I have a sales report as like below

enter image description here

I want to take Sale1person1 data if the Sale is Food Items and Sale1person2 if the Sale is Gadget and provide that to HTML file line

emailTemp.htmlsalevalue=row[???];

How to create if statement in emailTemp to get the corresponding data?

function myFunction() {
    var sale=9;
    var person1=10;
    var person2=11;
    
    var emailTemp = HtmlService.createTemplateFromFile("Table");
    var ws= SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Form Responses 3");
    var data = ws.getRange(ws.getLastRow(),1,1,ws.getLastColumn()).getValues();
    
    data.forEach(function(row){
    
        emailTemp.htmlsale=row[sale];
    
    })
}
James Z
  • 12,209
  • 10
  • 24
  • 44
Moses
  • 214
  • 1
  • 4
  • 12
  • Do you understand JavaScript arrays? – TheMaster Oct 21 '21 at 11:18
  • I am learning it. Is there any possible way for my request please – Moses Oct 21 '21 at 11:18
  • It is possible and I'm sure someone will post a readymade answer. In the mean time, try looking into [this](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/Arrays) and [this](https://stackoverflow.com/questions/63720612/what-does-the-range-method-getvalues-return-and-setvalues-accept) and see if you can figure it out on your own. – TheMaster Oct 21 '21 at 11:21
  • Have you been able to create the if statement with the documentation @TheMaster pointed you to? Also, the html file that is supposed to get the information for the table can you share it as well? – Kessy Oct 21 '21 at 15:56

0 Answers0