From 82e84354d53dfc2636b01c37a62fda84870a4f80 Mon Sep 17 00:00:00 2001
From: William Velzeboer <6429417+wimvelzeboer@users.noreply.github.com>
Date: Mon, 19 Jan 2026 10:52:04 +0000
Subject: [PATCH] Add getBooleanFieldByIdField method to fflib_SObjects2 (#72)
---
README.md | 3 ++
.../classes/domains/fflib_SObjects2.cls | 25 ++++++++++++
.../classes/domains/fflib_SObjects2Test.cls | 40 +++++++++----------
3 files changed, 46 insertions(+), 22 deletions(-)
diff --git a/README.md b/README.md
index 584d00d..76b57ff 100644
--- a/README.md
+++ b/README.md
@@ -53,6 +53,9 @@ Some of the changes that have major impact are listed here;
- **fflib_ArrayUtils**
_replaceValue_, Add three method overloads for merging a source map of idById and replacement map of idByString, idByDecimal or idByBoolean.
_mergeMaps_, Add method overload to merge two maps of idByBoolean,
+- **fflib_SObjects2**
+ The following methods have been added to the SObjects2 class:
+ _getBooleanFieldByIdField_
- **API Upgrades**
Upgraded to API 65.0
diff --git a/sfdx-source/apex-extensions/main/default/classes/domains/fflib_SObjects2.cls b/sfdx-source/apex-extensions/main/default/classes/domains/fflib_SObjects2.cls
index f2590f3..8680ab9 100644
--- a/sfdx-source/apex-extensions/main/default/classes/domains/fflib_SObjects2.cls
+++ b/sfdx-source/apex-extensions/main/default/classes/domains/fflib_SObjects2.cls
@@ -67,6 +67,31 @@ public virtual class fflib_SObjects2
SObjectDescribe = sObjectType.getDescribe();
}
+ /**
+ * Get a map with the given Boolean field value mapped to the given Id field
+ * Key fields containing null values are omitted
+ *
+ * @param valueField The Boolean field to use as value for the map
+ * @param keyField The Id field to use as key for the map
+ *
+ * @return a map with the given Boolean field value mapped to the given Id field
+ *
+ * @example
+ * Account account = Account.newInstance(records);
+ * Map isDeletedById = account.getBooleanFieldByIdField(Account.IsDeleted, Account.Id);
+ */
+ @TestVisible
+ protected virtual Map getBooleanFieldByIdField(Schema.SObjectField valueField, Schema.SObjectField keyField)
+ {
+ Map result = new Map();
+ Map