I have a map of sobject
s like this:
Map<String,list<sobject>> recordIdsMap = new Map<String,list<sobject>>();
Now my requirement is to iterate over this map, access the field and assign some value to it.
Code that I am currently trying for this:
for(Sobject target: recordIdsMap.values()){
target.BR_District__c = recorddestinationId;
obj.add(target);
}
But this isn't able to access the field name BR_District__c
because it can't identify the object type.
I suggest you use put(fieldName, value) method on your sObject (target in your case).
Should be smth like
for(Sobject target : recordIdsMap.values()) {
target.put('BR_District__c', recorddestinationId);
obj.add(target);
}