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
Class slaesforceClass slaesforce 

Error Error: Compile Error: Variable does not exist: Province at line 4 column 113

trigger Account on Account (after update) {
set<id> fire =new set<id>();
for(Account hg:trigger.new){
    if(hg.BillingStreet !=trigger.oldMap.get(hg.id)||hg.BillingCity!=trigger.oldMap.get(hg.id)||hg.BillingState/Province!=trigger.get(hg.id)||hg.BillingZip/PostalCode!=trigger.oldMap.get(hg.id)){
        fire.add(hg.id);
}
}
list<contact> cnt;
if(fire.size()>0){
  cnt=[SELECT name,AccountId FROM Contact where AccountId in:fire];
  }
  if(cnt!=null){
list<Contact>contr=new list<contact>();
for(contact von:cnt){
     von.otherStreet=trigger.newMap.get(von.id).BillingStreet;
     von.otherStreet=trigger.newMap.get(von.id).BillingCity;
     von.otherStreet=trigger.newMap.get(von.id).BillingState/Province;
     von.otherStreet=trigger.newMap.get(von.id).BillingZip/PostalCode;
     contr.add(von.id);
 }
 if(contr.size()>0){
 update.contr;
 }
 }
 }
Ashish DevAshish Dev
remove province, do something like this.
trigger.oldMap.get(hg.id)||hg.BillingState!=trigger.get(hg.id)||hg.BillingPostalCode

 
William TranWilliam Tran
use this:
 
trigger Account on Account (after update) {
set<id> fire =new set<id>();
for(Account hg:trigger.new){
    if(hg.BillingStreet !=trigger.oldMap.get(hg.id)||hg.BillingCity!=trigger.oldMap.get(hg.id)||hg.BillingState!=trigger.get(hg.id)||hg.BillingPostalCode!=trigger.oldMap.get(hg.id)){
        fire.add(hg.id);
}
}
list<contact> cnt;
if(fire.size()>0){
  cnt=[SELECT name,AccountId FROM Contact where AccountId in:fire];
  }
  if(cnt!=null){
list<Contact>contr=new list<contact>();
for(contact von:cnt){
     von.otherStreet=trigger.newMap.get(von.id).BillingStreet;
     von.otherStreet=trigger.newMap.get(von.id).BillingCity;
     von.otherStreet=trigger.newMap.get(von.id).BillingState;
     von.otherStreet=trigger.newMap.get(von.id).BillingPostalCode;
     contr.add(von.id);
 }
 if(contr.size()>0){
 update.contr;
 }
 }
 }



As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.

Thanks