Add getDecimalById to fflib_SObjects2
Signed-off-by: WimVelzeboer <william@velzeboer.nl>
This commit is contained in:
@@ -246,6 +246,27 @@ public virtual class fflib_SObjects2
|
||||
.getDateTimeFieldValues(sObjectField);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param decimalField The field to use as the Value of the returned Map
|
||||
* @param idField The field to use as the Key of the returned map
|
||||
*
|
||||
* @return Returns a map with the values of two fields
|
||||
*/
|
||||
@TestVisible
|
||||
protected virtual Map<Id, Decimal> getDecimalById(Schema.SObjectField decimalField, Schema.SObjectField idField) {
|
||||
Map<Id, Decimal> result = new Map<Id, Decimal>();
|
||||
for (SObject record : getRecords())
|
||||
{
|
||||
if (record.get(idField) == null) continue;
|
||||
|
||||
result.put(
|
||||
(Id) record.get(idField),
|
||||
(Decimal) record.get(decimalField)
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sObjectField The Schema.SObjectField to get the SUM of
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user