You need to sign in to do that
Don't have an account?
variable does not exist
This question is from my practise when we update a field on the account object when there is an action on the contact object do we need to mention the particular record type of the record to make the update by a trigger.
Why Iam asking this is by the following code i noticed an error on the contct obj but where as not on the opportunity
The compiler error is AccountId does not exist.
With some modifications a part this code i tested with the opportunity obj, but there is no error.
trigger primaryPhone on Contact(before Insert){
set<Id> ids = new set<Id>();
for(Contact cnt : Trigger.New){
ids.add(cnt.AccountId);
}
Map<Id, Account> accMapIds = new Map<Id, Account>([Select Id,Phone from Account where Id
IN: ids]);
List<Account> act = new List<Account>();
for(Contact ct : trigger.New){
if(ct.Primary__c == True){
Account acc = accMapIds.get(ct.AccountId);
acc.Phone = ct.Phone;
act.add(acc);
}
}
Update act;
}
Plz share your ideas and suggestion
Thanks in advance
just a hunch, check to see if you or someone else on your org created a class called 'Contact'.
All Answers
just a hunch, check to see if you or someone else on your org created a class called 'Contact'.
Thank you very much