RemcoE33

uncheck in 24 hours

Jun 1st, 2021 (edited)
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const criteriaSheet = 'Data'
  2. const env = PropertiesService.getScriptProperties()
  3. const timestamp = env.getProperty('timestamp')
  4. const d2Value = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(criteriaSheet).getRange('D2').getValue()
  5.  
  6. function onEdit(e){
  7.   if(e.value = true && e.source.getActiveSheet().getName() == criteriaSheet && e.source.getActiveSheet().getActiveCell().getColumn() == 1 && d2Value == false) {
  8.     const timestampValue = new Date().getTime()
  9.     env.setProperty('timestamp',timestampValue)
  10.   }
  11. }
  12.  
  13. function check24(){
  14.   const now = new Date().getTime()
  15.   const difference = now - timestamp;
  16.  
  17.   if(difference >= 86400000){
  18.     SpreadsheetApp.getActiveSpreadsheet().getSheetByName(criteriaSheet).getRange("D2").uncheck()
  19.   }
  20. }
  21.  
  22. function checkEnvManually(){
  23.   console.log(timestamp)
  24.   const date = (timestamp) ? new Date(Number(timestamp)) : 'No timestamp is set'
  25.   console.log(date)
  26. }
Add Comment
Please, Sign In to add comment