I have many Custom Objects in my package that have a common custom field Version__c. One part of my app serializes and deserializes records to/from Json. While deserializing I want to change this Version field for any record which is of a type that has this field.
The code looks like this:
private SObject createVersion(SObject oldRecord) {
SObject newRecord = oldRecord.clone();
if(isFieldAvailableOn('Version__c', oldRecord)) {
newRecord.put('Version__c', oldRecord.Version__c);
}
return newRecord;
}
How can I implement isFieldAvailableOn(String fieldName, SObject record)
without consuming Describe call?