You need to sign in to do that
Don't have an account?
Help with Update Parent Account
I have a visual force page which shows a list of Accounts. Then the user select one account, and when he clicks the button it should assign that selected account as the Parent account in another Account.
Account a=[Select Id,Name from Account WHERE id=:ApexPages.currentPage().getParameters().get('id')];
Account parentAccount = [Select Id,TIN_Company__c, Name from Account WHERE id=:selectedValue];
a.Parent=parentAccount ;
try{
Update a;
}catch (Exception e){
}
When I execute that code I get no error, In the log I can see the name and Id of both accounts, but no update is performed.
What am I doing bad?
Thanks!
Hi instead of line
a.Parent = parentAccout;
use
a.parentId = parentAccount.Id and update it.
See the relation between account and parent is by lookup whenever there is a lookup the reference is through id's
Hope this may help else please reply back.
Thanks
George
All Answers
Hi instead of line
a.Parent = parentAccout;
use
a.parentId = parentAccount.Id and update it.
See the relation between account and parent is by lookup whenever there is a lookup the reference is through id's
Hope this may help else please reply back.
Thanks
George
Try like this
a.ParentId = parentAccount.Id;
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks