You need to sign in to do that
Don't have an account?
Ram Arza
Error: Compile Error: Invalid field OwnerId for SObject User
I have trouble comparing old and new Account OwnerID. I see an error message saying "Error: Compile Error: Invalid field OwnerId for SObject User at line 13 column 46". Below is my code. Please assist.
trigger ContactOwnerID on Account (After Insert, After Update) { List<Account>AccList = new List<Account>(); Map<id,user>OldUserMap = new Map<id,user>(); Map<id,user>NewUserMap = new Map<id,user>(); List<Contact>ConList = new List<Contact>(); List<Contact>UpdatedConList = new List<Contact>(); List<Contact>FinalConList = new List<Contact>(); For(Account A:Trigger.new){ If(A.OwnerId != Null && OldUserMap.get(A.id).OwnerId != NewUserMap.get(A.id).OwnerId){ AccList.add(A); } If(!AccList.isEmpty()){ ConList =[Select id, OwnerId, AccountId from Contact where AccountId =: AccList]; } } If(!ConList.isEmpty()){ For(Contact c:UpdatedConList){ c.OwnerId = c.account.ownerid; FinalConList.add(c); } } If(!FinalConList.isEmpty()){ Update FinalConList; } }
Hi Ram,
Hope it will helps you :)
All Answers
Hi Ram,
Hope it will helps you :)