function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
A chauhanA chauhan 

how to access account name in opportunity object using custom controller

i  am using custom controller for opportunity and i have field on my page account name, when i enter account name and submit it does not et store in opportuity  i want to fetch and store account name in opportunity object when i click submit button my VF page.
Deepak agarwal 9Deepak agarwal 9
Hi A chauhan,

You can access account name from opportunity by writting SOQL

[select accountname from opportunity where: mention condtion like id];

opportunity contains accountname as a field.By that you will get all the account names having opportunity.

Mark it as best to help others.

Thanks,
Deepak
Dilip_VDilip_V
Hi chauhan,

Use this query
 
Account Acc=[Select name,Id from account where Id=: Opportunity.accountID];

Share your code if it doesn't work
Ajay K DubediAjay K Dubedi
Hi,
Used below query in your controller code :
 Query SELECT Id,Name, Account.Name FROM Opportunity LIMIT 10000
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi