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..
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityi 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..
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.
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.