Attempting to retrieve a field not acquired by soql will result in the following error.
SObject row was retrieved via SOQL without querying the requested field: object.field__c
In order to prevent this error from occurring, we know that we need to add fields that we did not get in soql.
Is it possible to write a process to set a null character in a String variable without getting the above error when trying to acquire an unfetched field?
Refer to the following article Check is SObject has certain field
I implemented the following code, but I got an error.
Public static boolean hasSObjectField (String fieldName, SObject so) {
Return so.getSobjectType().GetDescribe().Fields.getMap().KeySet().Contains (fieldName.toLowerCase ());
}