I have a sheet that gets updated through ImportRange. There is a column in that sheet that represents the performance of the customer. It can either be performing or underperforming based on a data set that exists in our CRM.
| Customer Name | Performance Status |
|---|---|
| Customer1 | performing |
| Customer2 | underperforming |
These statuses change throughout the week I'm trying to run a script that logs all these changes per customer, and ideally, notifies me when the status changes to underperforming.
Here's what I have so far:
function performance(e) {
Logger.log (e.changeType);
// if (e.changeType =="OTHER") return;
let props = PropertiesService.getScriptProperties().getProperties();
const sh = SpreadsheetApp.getActive();
const ss = sh.getSheetByName("sheetname");
for (let p in props) {
let r = ss.getRange(p);
let val = r.getValue();
// if(val != props[p]){
// r.offset(1,0).setValue(props[p]);
Logger.log(PropertiesService.getScriptProperties().setProperty("data",ss.getRange("A7:N").getValues()));
// }
}
Regarding the set_properties, it returns this format. Not sure how to access those values and how to compare them with the previous values.
function set_properties(){
const sh = SpreadsheetApp.getActive();
const ss = sh.getSheetByName("sheetname");
var range = ss.getRange("A7:N");
var values = range.getValues();
// This logs the spreadsheet in CSV format with a trailing comma
for (var i = 0; i < values.length; i++) {
var row = "";
for (var j = 0; j < values[i].length; j++) {
if (values[i][j]) {
row = row + values[i][j];
}
row = row + ",";
}
Logger.log(row);
}
PropertiesService.getScriptProperties().setProperty('data',row);
}