Hello I am trying to write a script that detects duplicates. Currently the if statement is triggered and it increase i(which tells me how many duplicates their are), even when the two fields do not match.
let table = base.getTable(“Policy”);
let view = table.getView(“All Fields”);
let first = table.getField(“PolicyNumber”); //Lookup Field
let sec = table.getField(“PolicyNumber”);
let result = await view.selectRecordsAsync({
sorts: [{field: “PolicyNumber”, direction: “asc”}]});
let result2 = await view.selectRecordsAsync({
sorts: [{field: “PolicyNumber”, direction: “asc”}]});
for (let record1 of result.records) {
let thedup = record1.getCellValue(first)
let i = 0;
output.text(thedup)
for (let record2 of result2.records){
let cop = record2.getCellValue(sec);
output.text(cop)
if (thedup=cop){
i++
if(i>1){
output.text(“help”)
}
}
}
}
This is the output i currently have 12 entires:
B0750RNMFP1709519 - 001
B0750RNMFP1709519 - 001
B0750RNMFP1709519 - 003
help
B0750RNMFP1709519 - 004
help
B0750RNMFP1709519 - 027
help
B0750RNMFP1709519 - 051
help
B0750RNMFP1709519 - 058
help
B0750RNMFP1709519 - 058
help
B0750RNMFP1709519 - 058
help
(the list goes on)
it basicly counts every option as = and increasing i with each interaction
