add getIdFieldByStringField()

This commit is contained in:
Jan Aertgeerts
2022-01-10 11:49:20 +01:00
parent 24ba673d8e
commit bc62708b88
3 changed files with 55 additions and 0 deletions
+13
View File
@@ -29,6 +29,7 @@ Protected methods
- [getDoubleFieldValues](#getdoublefieldvalues)
- [getFieldByField](#getfieldbyfield)
- [getFieldsByField](#getfieldsbyfield)
- [getIdFieldByStringField](#getidfieldbystringfield)
- [getIdFieldByIdField](#getidfieldbyidfield)
- [getIdFieldsByIdField](#getidfieldsbyidfield)
- [getIdFieldValues](#getidfieldvalues)
@@ -138,6 +139,18 @@ Contacts contacts = Contacts.newInstance(records);
Map<Object, Set<Object>> contactIdByAccountId = contacts.getFieldsByField(Contact.Id, Contact.AccountId);
```
<br/><br/>
#### getIdFieldByStringField
Get a map with the string field as the key and the ID as values. Key fields containing null values are omitted.
`protected Map<String, Id> getIdFieldByStringField(Schema.SObjectField valueField, Schema.SObjectField keyField)`
_Example_
```apex
Contacts contacts = Contacts.newInstance(records);
Map<String, Id> accountIdByContactId = contacts.getIdFieldByStringField(Contact.Id, Contact.Name);
```
<br/><br/>
#### getIdFieldByIdField
Get a map with the values of two Id fields. Key fields containing null values are omitted.