i'm new google apps script , need figuring out how code spreadsheet. spreadsheet populated user submitting form. row color change depending on response of column. here have far:
function colorrow(){ var sheet = spreadsheetapp.getactivespreadsheet().getsheetbyname("requests"); var range = sheet.getdatarange(); // row var row = range.getrow(); // cell value compare var cellvalue = range.getvalue() if(cellvalue == "cancel interpreter request"){ datarange.setbackgroundrgb(255, 0, 0); } else if(cellvalue == "next day interpreter request"){ datarange.setbackgroundrgb(201, 218, 248); } else if(cellvalue == "update existing interpreter request"){ datarange.setbackgroundrgb(255, 255, 0); } else if(cellvalue == "same day request"){ datarange.setbackgroundrgb(106, 168, 79); } spreadsheetapp.flush(); } function onsubmit(e){ colorrow(); }
any ideas?
getactivespreadsheet()
applicable when editing spreadsheet. when user submits form, there no active spreadsheet. use spreadsheetapp.openbyid()
instead.
also, getdatarange()
gives range of entire sheet. if looking row recent form submission entered, use e.range
function colorrow(datarange){ // cell value compare var cellvalue = datarange.getvalue() if(cellvalue == "cancel interpreter request"){ datarange.setbackgroundrgb(255, 0, 0); } else if(cellvalue == "next day interpreter request"){ datarange.setbackgroundrgb(201, 218, 248); } else if(cellvalue == "update existing interpreter request"){ datarange.setbackgroundrgb(255, 255, 0); } else if(cellvalue == "same day request"){ datarange.setbackgroundrgb(106, 168, 79); } spreadsheetapp.flush(); } function onsubmit(e){ colorrow(e.range); }
Comments
Post a Comment