I am using Google Apps Script
I have a Google Sheet where column 1 has 120 domain names (120 rows) and i need to write the status of these domains as "Domain Verified" / "Domain Not Verified" in Column 7
I wrote a script which is using Admin Directory API service and using AdminDirectory.get.domains.verified which results in boolean (True = domain verified, False = domain not verified) to check the status of domains to see if they are verified domains in google.
my below script works absolutely fine, it checks for each domain name row and puts the status as either in column 7, however the problem is that my loop stops as soon as it comes to any domain which is NOT yet registered in Google, in the logs it says "Execution failed: Domain not found. (line 36, file "Code") [1.412 seconds total runtime]"
where i expect it to be running till the last row (120th) regardless of the result.
What I actually want is, regardless of the result, my loop should cover all 120 rows, can you help?
Here is my Script-:
function domainList() {
var ss = SpreadsheetApp.getActiveSpreadsheet()
var sheet = ss.getActiveSheet()
var data = sheet.getRange("B2:B").getValues()
var customer = "my_customer"
for(i=0; i<data.length; i++){
var dcheck = AdminDirectory.Domains.get(customer, data[i]);
var status = dcheck.verified
if(status === true){
status = "Domain Verified"}
else if(status === false){
status = "Domain Not Verified"}
else if(status === ({})){
continue;
}
Logger.log(status)
var range = ss.getSheets()[0].getRange(2+i, 7).clear()
var range = ss.getSheets()[0].getRange(2+i, 7)
range.setValue(status)
}}