I have a logic issue with the next code which I cannot manage to solve.
I will receive a Map<String, List<Sobject>> recordsMap
and I need to match the String which will be the object name and get the List and match it with the mapping fields
public List<SubsExtendedInfo> generateWrapperInfo (Map<String, List<Sobject>> recordsMap){
//object Name >> records
Map<String, SubscriberMapping__c> mappingFieldsMap = SubscriberMapping__c.getAll();
// This mappingFieldsMap has the name of the object with the mapping fields
// The obj name should match with the map string and then by its name get the equivalent mapping fields List<Sobject> - mappingFieldsMap
// mappingFieldsMap.get(Key).SF_Object_API_Name__c
// This is the object name field from the mappingFieldsMap
return null;
}
I cannot figure out how to do it, could anyone help me?
SubscriberMapping__c Structure
Product Field Name || FieldName__c
Object API Name || SF_Object_API_Name__c
SF_Field_API_Name || SF_Field_API_Name__c
SubscriberMapping__c Values
Name || Product Field Name || Object API Name || SF_Field_API_Name
Contact-Email || Email || Contact || Email
Contact-First Name || First Name || Contact || FirstName
And the Map will the String for the obj name and List is the object with its fields and values, the fields are the same as SF_Field_API_Name in the custom setting.
So I should match the obj name and then the field names to get its values.
Best Answer
If I can understand your requirement correctly, here will be the code.