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
acrozieracrozier 

Getting AccountId from Quote

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

acrozieracrozier

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
Class.YTDAccountEXT.

 

Please help

 

Andy BoettcherAndy Boettcher

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

 

-Andy

acrozieracrozier

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;