test

I used PasteBin to get this look.

  1. function rDeletor() {
  2.   var ss = SpreadsheetApp.getActive()
  3.   var sheet = ss.getSheetByName("Delete Resources")
  4.   var DHeading = sheet.getRange("A1:B1").setValues([["Resource Id of calendar to be deleted", "Deletion Status"]])
  5.   var values = sheet.getDataRange().getValues();
  6.   Logger.log(values)
  7.   if(!values){
  8.     Logger.log(values)
  9.     Browser.msgBox("Oh Oh, seems you forgot to provide required fields like Resrouce Name or Resource Id \\n  please provide them to create resources \\\\n Regards, \\n Goldy Arora \\n G Suite Certified Consultant \\n www.goldyarora.com")
  10.   }
  11.   var column1 = sheet.setColumnWidth(1,250)
  12.   var column2 = sheet.setColumnWidth(2,250)
  13.   var column4 = sheet.setColumnWidth(4,250)
  14.   var decorate = sheet.getRange("A1:B1").setBackground("#E91E63").setFontColor("#ffffff").setFontWeight("Bold")
  15.   var fileArray = [["Deletion Status"]]
  16.   var customer = "my_customer"
  17.   for (i=1; i<values.length; i++){
  18.     var resourceId = values[i][0];
  19.     try{
  20.       if(resourceId == ""){ var status = "Required details not provided" }
  21.       if(!resourceId == ""){
  22.         //Avoid hitting google limits
  23.         Utilities.sleep(2000)
  24.         //Make sure you enable Admin Directory
  25.         status = AdminDirectory.Resources.Calendars.remove(customer,resourceId)
  26.         Logger.log(status)
  27.         if(status === "Resource Not Deleted"); { status = "Resource Deleted Successfully" }
  28.       }
  29.     }
  30.     catch (e){
  31.       var status = e.message
  32.       Logger.log(status)
  33.     }
  34.     fileArray.push([status])
  35.   }
  36.   sheet.getRange(1,2,fileArray.length, 1).setValues(fileArray)
  37. }
Comments