So i have two copies of an object and i want to copy over most but not all of the fields from one to the other. Luckily, i use naming conventions to help, all the fields i need to copy over start with Assets
or Banking
so this is what im playing with
Map<String, Schema.SobjectField> MeetingFields = Schema.SObjectType.Meeting__c.fields.getMap();
for(String key : MeetingFields.keySet()) {
if (key.startsWith('Assets') || key.startsWith('Banking') ) {
meeting[key] = prevMeeting.get(key);
}
}
the two objects, meeting and prevMeeting are both Meeting__c sObjects..
It does loop through all the fields and key is fine but how do i get the key from each object to do the copy?
I tried
meeting[key] = prevMeeting.get(key);
meeting.get(key) = prevMeeting.get(key);
Is there an easier way to do this?