SearchEngine vs Selections on company category

lock
push_pin
done
Beantwortet
1

Wondering why when i make a Selection of companies that have the category of "Eksisterende Kunde", i get a total of 487 companies, however when i try to make a script to catch all of these existing companies, i get a total of 244? (Category "Eksisterende kunde" is category_idx = 1)

 

SearchEngine se;
se.addFields("contact", "name,contact_id,category_idx.name,category_idx");
se.addCriteria("contact.category_idx", "OperatorEquals", "1");

Integer count = 0;

for (se.execute(); !se.eof(); se.next()) {
  print(se.getField(0) + " | " + se.getField(1) + " | " + se.getField(2) + " | " + se.getField(3) + "\n");
  se.next();
  count++;
}

print(count.toString());

27. März 2025 | 05:59 AM

Alle Antworten (1)

Hi Frederic

You are running se.next() twice, both in your if statement and inside your code block. That makes you skip counting every other contact. 🙂

By the way, you could also just run se.countRows(), that will give you the correct amount of rows (just note that count won't be limited if you've limited the result with se.setLimit()).

27. März 2025 | 07:28 AM

Antwort hinzufügen