You need to sign in to do that
Don't have an account?
Vikram Singh 157
i want to update an account name based on their contact where contact first name = null, i am getting error in below code
Contact C = [SELECT Account.Name FROM contact where FirstName= 'vikky'];
C.Account.Name = 'SFDC';
update C;
system.debug (C);
system.debug(C.Account.Name);
C.Account.Name = 'SFDC';
update C;
system.debug (C);
system.debug(C.Account.Name);
Try above code and let me know If you have any question.
All Answers
To make any DML statement on salesforce record you are required to have Unique ID (Salesforce ID). Please query ID and try the same code.
Try above query and rerun the code.
Thanks,
Gaurav
Try above code and let me know If you have any question.
For updating account you have to provide object instance of account with "update" statement instead of contact.
Here are few suggestion and adjustments:
1) Provide instance of account instead of contact. So, we have instead of This will update contact.
2) Final code:
If this resolve your problem, please mark this as solved , so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.
Thanks & Regards
Gulshan Raj
LinkedIn (https://www.linkedin.com/in/gulshan-raj-a26b0640/)
Twitter (https://twitter.com/gulshan_bittoo)
Thnaks Mr. GulshanRaj it works