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
swapna9swapna9 

How to prepopulate opportunity name in quote visualforce page

Hi,

 

I have done visualforce page for satndard quote.I want to prepopulate opportunity name in this visualforce page.

 

Can any one give idea.

 

Thanks in advance

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Chi-Towns FinestChi-Towns Finest

If you are using a StandardController in your constructor parameters, you could do the following:

 

public with sharing class TestClass

{

     public Opportunity opp {get; private set;}

     private Quote q;

 

     public TestClass(ApexPages.StandardController stdController)

     {

          q = (Quote)stdController.getRecord();

          opp = [Select Id, Name From Opportunity Where Id =: q.OpportunityId];

     }

}

 

This gets the Quote from the page, regardless of if it is on a create new or edit action, and pulls the parent (Opportunity) in for you. You just have to query to get other fields, in this case Name. This should work and I hope it helps.

All Answers

Chi-Towns FinestChi-Towns Finest

If you are using a StandardController in your constructor parameters, you could do the following:

 

public with sharing class TestClass

{

     public Opportunity opp {get; private set;}

     private Quote q;

 

     public TestClass(ApexPages.StandardController stdController)

     {

          q = (Quote)stdController.getRecord();

          opp = [Select Id, Name From Opportunity Where Id =: q.OpportunityId];

     }

}

 

This gets the Quote from the page, regardless of if it is on a create new or edit action, and pulls the parent (Opportunity) in for you. You just have to query to get other fields, in this case Name. This should work and I hope it helps.

This was selected as the best answer
swapna9swapna9

Thanks for ur reply,

 

Its working....