You need to sign in to do that
Don't have an account?
Trigger issues, need help
trigger ContactNameUpdate on account(before insert, before update)
{ if(trigger.isupdate){
for(account a:trigger.new);
{
if((contact.Title = 'Accounts')){
contact.FirstName = account.Contact_First_Name__c ;
contact.LastName = account.Contact_Last_Name__c ;
}}}}
Error Message: Error: Compile Error: Expression cannot be assigned at line -1 column -1
What I am trying to accomplish here is to Pull the Contact1st and last names from the contact object if Title = Accounts and bring over to the Account object into two custom fields Contact_First_Name__c and Contact_Last_Name__c
I know I am cross referencing objects, but honestly have no idea how to do this right....
Thanks for the help!
Write this like this
Removed semicolon from : for(account a:trigger.new);
And changed this
contact.Title = 'Accounts' to contact.Title == 'Accounts'
as condition can not have = ( assignment operator)
Hi Shashi,
I orignally had the double = as in == I get the same exact error message. I just changed it and tried too.
Thanks
Ok you are using contact where you ahve not fetched contact try this
I tried this and I get the error
Error: Compile Error: Variable does not exist: a.id at line 4 column 73
ok
try this
Still not working.
Thank you for all your help! Really appreciate it. error is below
Error: Compile Error: Illegal assignment from Schema.SObjectField to String at line 9 column 14
ohh this is so bad I am missing such things
try this
So the trigger was saved successfully, but upon trying to edit an Account record to see if it works correctly I get this error....
do this change
Did it worked for you?
The trigger saves and no error on saving the account record. But the Contact First Name and Contact Last Name fields are blank....not populating
You must be having more than one contact on the account on which you are testing try this an then test
Hi Shashi,
I have given up on this trigger. It acts erratically, wont let me delete contact records and it does not update the fields on the account object. My solution was to use workflow rules instead.
I appreciate all your help.
Thanks,
V