Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

179
Visualizações
Onchange AppScript - Create History Of Changes For Specific Column

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.

  1. Since it's ImportRange, I've been using the onChange trigger.
  2. To store & retrieve the old values, I'm using the PropertiesService
  3. Haven't figured out how to compare these two datasets to trigger a notification.

Here's what I have so far:

  1. Trigger function:

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);

}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda