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

Getting AccountId from Quote

How can I get the related AccountId from the Opportunity with Quote as my controller?


I am trying this:


 public String getAccountId(){
    	Quo = apexpages.currentpage().getParameters().get('id');
    	Opportunity Opp = [SELECT Account__c FROM Opportunity Where SyncedQuoteId =:Quo];
		AccountId = Opp.Account__c;
	return AccountID;

 but getting the following error:


System.TypeException: Invalid conversion from runtime type SOBJECT:Quote to SOBJECT:Account


Please help


Andy BoettcherAndy Boettcher

There are variables in your posted code that are instanciated elsewhere.  Can you post your full code?




Can someone please tell me how I can get the Account ID from the Quote object??

Andy BoettcherAndy Boettcher

Id idOpportunity = <if you're in the Quote controller, you can access this Id from the Quote record>

Opportunity opp = [SELECT AccountId FROM Opportunity WHERE Id = :idOpportunity];


Id idAccount = opp.AccountId;