0

i want to crate a new quote from my own custom controller and visualforce page can any one help me doing the same. as i don't have idea how to do it.

Thanks in advance..

  • 1
    Welcome to SFSE - This forum is for help you get around specific problems with code you have written. It is NOT a forum to ask people to write code for you. There are many developers / consulting services you can hire to do that for you. – Eric Jun 22 '15 at 5:20
  • Hi "crmevengelist", it may be easier for us to help you if we know why you don't have an idea how to do this. Are you new to visualforce or apex ? Have you never used the quote object before ? Are you not sure what fields or business requirements you have ? By explaining us your thought-process and context, we can do a better job helping you. You can still edit the question to share more details, doing so will help us help you. – Samuel De Rycke Jun 22 '15 at 10:55
6

You can take help from below: controller :

public with sharing class QuoteController {

public Quote q {get;set;}
public string qName{ get; set;}


public QuoteController(ApexPages.StandardController sc) {
    q = new Quote();
    q = (Quote)sc.getRecord();

   } 
public Pagereference saveQuote() {
q.name = qName;
      q.opportunityid = '0069000000OaWIM';     
    insert q;
    pagereference pageref = new pagereference('https://ap1.salesforce.com/'+q.id);
    pageref.setredirect(true);
    return pageref;

}    
}

vf page:

 <apex:sectionHeader title="Quote" subtitle="New Quote"/>
 <apex:form id="formId" >

  <apex:pageBlock id="pgBlock" title="Quote " >
   <apex:pageBlockButtons id="pgBlkBtn" >
    <apex:commandButton id="saveBtn" value="Save" action="{!saveQuote}"  />
    <apex:commandButton id="cnclBtn" value="Cancel" action="{!cancel}" />
   </apex:pageBlockButtons>
   <apex:pageBlockSection id="pgBlkSection1" title="Quote Information" columns="2">
    <apex:pageBlockSectionitem >
     <apex:outputLabel value="Quote Name" />
     <apex:inputtext value="{!qName}" />
    </apex:pageBlockSectionitem>


    </apex:pageBlockSection>
  </apex:pageBlock>
 </apex:form>

</apex:page>

Let me know if this helps.

  • a lot of thanks to u. code works and i have finished my assignment.One thing remains is i want to generate quotation pdf according to my own template i mean i am creating new customized template but it is not giving me facility to arrange the field and decorate page according to my own format.so, is there any idea about that. – Prabhat Ranjan Jun 22 '15 at 8:17
  • sorry but i dont know about that mate. – Ajay Dubedi Jun 23 '15 at 8:41
2

An option which I think you'll find quite helpful for you needs is to install the unmanaged package version of Custom Quote Sync from the App Exchange. It has a Quote controller that you can always clone and customize to suit your specific needs. It comes with a VisualForce PDF template which can also be cloned and customized. I and others I know, use it all the time with clients as a basis for creating customized PDF Quote generators that sync with Opportunity.

There's also another unmanaged package called Simple Quote v1.0 which allows you to generate a quote instantly as a pdf and send it via email in 2 clicks. You can easily customize the template to use it for orders or invoices. Either of these should suit your needs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.