dimanche 24 avril 2022

How to create a trigger to store data from two columns: trigger on completing a checkbox checklist

new to code and most of what I have, is copied from a mix of code found online. Apologies if it's messy and please explain simply as possible (:

I'm trying to (onEdit)trigger a function saveData that will move the comment section in A9, generating a timestamp in B9 and then moving both values from A9 and B9 and storing them 2 rows lower. The aim is to be able to check the "tasks" each week and write any comments and then completing the checklist will trigger storing that information in a lower row that then appends the values each time its completed.

Grateful for any direction / suggestions.

Screenshot of spreadsheet ¬

function onEdit(){
  var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var activeCell = ss.getActiveCell();      
  if( activeCell.getRow() == 7)
  if( activeCell.getColumn() == 3) {         
    saveData();    
 }

function saveData() {
  const ss = SpreadsheetApp.getActiveSpreadsheet();
  const sheet = ss.getSheets()[0];
  const comments = sheet.getRange('Sheet1!A9').getValue();
  const timestamp = sheet.getRange('Sheet1!B9').getValue(); 
  sheet.appendRow([comments,timestamp]); }

}



Aucun commentaire:

Enregistrer un commentaire