diff --git a/force-app/main/default/classes/SOQL.cls b/force-app/main/default/classes/SOQL.cls index 63711e6..4aec1e6 100644 --- a/force-app/main/default/classes/SOQL.cls +++ b/force-app/main/default/classes/SOQL.cls @@ -547,11 +547,10 @@ public virtual inherited sharing class SOQL implements Queryable { public Set toValuesOf(SObjectField fieldToExtract) { // https://salesforce.stackexchange.com/questions/393308/get-a-list-of-one-column-from-a-soql-result builder.fields.clearAllFields(); // other fields not needed - try { - return new Map(with(fieldToExtract, 'Id').groupBy(fieldToExtract).toAggregated()).keySet(); - } catch (ListException e) { // Row with null Id at index: 0 - return new Set(); - } + return new Map(with(fieldToExtract, 'Id') + .whereAre(Filter.with(fieldToExtract).isNotNull()) + .groupBy(fieldToExtract).toAggregated()) + .keySet(); } public Integer toInteger() {