function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
akhil Vakhil V 

Field expression not allowed for generic SObject

if(lo.lat__c == null || lo.long__c == null || (lo.Zip_Code__c != null && Trigger.oldMap.get(lo.id).Zip_Code__c != lo.Zip_Code__c)) getting this error in this statement can one help out urgent
Best Answer chosen by akhil V
Bhanu PartapBhanu Partap
Trigger.oldMap.get(lo.id).Zip_Code__c // problem is here
Trigger.oldMap.get() return sobject, first type cast it to object on which you are writing trigger then use that variable to reffer its Fields "Zip_Code__c".

like this

trigger Winning on Opportunity (before update) { 
for (Opportunity opp : Trigger.new) {
Opportunity oldOpp = Trigger.oldMap.get(opp.Id); // see here
}
}

All Answers

Bhanu PartapBhanu Partap
Trigger.oldMap.get(lo.id).Zip_Code__c // problem is here
Trigger.oldMap.get() return sobject, first type cast it to object on which you are writing trigger then use that variable to reffer its Fields "Zip_Code__c".

like this

trigger Winning on Opportunity (before update) { 
for (Opportunity opp : Trigger.new) {
Opportunity oldOpp = Trigger.oldMap.get(opp.Id); // see here
}
}
This was selected as the best answer
Bhanu PartapBhanu Partap
 or directly use String.valueof(Trigger.oldMap.get(lo.id).Zip_Code__c)  != String.valueof(lo.Zip_Code__c) .