I'm trying to check whether there are duplicate phone numbers in a column and to then return the first id number associated with the phone match in google apps script.
I created an if statement, according to every reference I've checked I've coded it right. The script runs but nothing populates??
I defined the ranges for the count that has the phone number and id number associated with it. I ensured its in the correct array my using map and used a basic if else statement.
Everything seems to run but the statement doesn't throw out the id numbers. In fact nothing happens.
Please help...
function myFunction() {
var sss = SpreadsheetApp.openById('spreadsheetid'); // sss = source spreadsheet
var ss = sss.getSheetByName('spreadsheetname'); // ss = source sheet
var lr = ss.getLastRow();
for (var i=3;i<lr;i++) {
var phone = ss.getRange(i,4,lr).getValues();
var id = ss.getRange(i,1,lr).getValues();
var phonearray = phone.map(function(r){return r[0]});
if(phonearray == phone[i]){
//emailarray.indexOf(email[i]) &&
ss.getRange(i,30,lr).setValue(id[i]);
} else
ss.getRange(i,30,lr).setValue("");
}
}