+ Start a Discussion
yvk431yvk431 

Customize create PDF on Quote

Hi, please respond if any one came across this functionality,

 

we happened to disable, enable the create pdf button on the quote based on a status field. How to proceed with this.

 

I found 2 option to override the standard with a visual force page or using a custom button.

 

In both the case i ran out of option on to fins the quote template id and use it in the creation of the pdf. 

 

Any ideas on this

Best Answer chosen by Admin (Salesforce Developers) 
ShamilShamil

I think the best you can do is piggyback on top of the out-of-the-box quote-to-pdf functionality. Based on your explanation I didn't fully understand if that was the case.

 

The following URL will generate a pdf for a quote with ID: 0Q0C0000000Hgjw  and template ID: 0EHC0000000PavI in na8 instance:


https://na8.salesforce.com/quote/quoteTemplateDataViewer.apexp?id=0Q0C0000000Hgjw&headerHeight=10&footerHeight=10&summlid=0EHC0000000PavI#toolbar=1&navpanes=0&zoom=90

 

I don't think quote template Ids can be obtained programmatically, so you may have to store the Quote Template  Name => Id mapping in custom settings or in a custom object.

Your flow would be:

1. User presses on the custom 'Generate PDF' button

2. Your VF controller logic kicks-off and if in this scenario the button shouldn't do anything will display an error message

3. If PDF creation is allowed, user will be displayed a 'Select Template' page where you'd show them their options in a drop-down box, which would be populated from a custom setting/object

4. user selects the template and you redirect them to a URL similar to the following:

https://na8.salesforce.com/quote/quoteTemplateDataViewer.apexp?id=0Q0C0000000Hgjw&headerHeight=10&footerHeight=10&summlid=0EHC0000000PavI#toolbar=1&navpanes=0&zoom=90

 

Hope this helps.

All Answers

Starz26Starz26

Well,

 

If I understand you correctly, you need to disable the quote button or enable it base on a field value?

 

If so, when createing the VF page for quotes, after selecting the value in the drop down:

 

1. Call a java function that adds a class to the quote button (using selectors) called 'hideme' when you want it hidden, or remove "hideme" when you want it to show

2. have CSS on the page that sets the class of .hideme to display:none;

 

This should accomplish what you need if I understood it correctly

 

Starz26Starz26

Here is a quick example using jQuery. I can never get pur java to work.....

 

here we are using one of our custom fields on account that contain various values including 'Unknown'. When Unknown is selected the edit button goes away, when anything else is selected it stays or reappears.

 

Obviously this is set up using the detail component with the field outside of the component so you will have to build your page or figure out a way to determine if a value inside the detail has changed.

 

 

 

<apex:page standardController="account" Title="DLH Region Accounts" tabstyle="Account">

<!-- jQuery 1.7.min javascript Included as a static resource -->
<apex:includeScript value="{!URLFOR($Resource.jQuery17Min)}"/>

<style>
.hideMe  {

  display: none;

}

</style>

<script>
var j$ = jQuery.noConflict();

function setCSS(a){

if(a == 'Unknown')
    j$('input[name="edit"]').addClass("hideMe");
else
    j$('input[name="edit"]').removeClass("hideMe");


}
</script>

<apex:form >

<apex:inputfield value="{!Account.Access_Level_Outside_of_Lab__c}" onchange="setCSS(this.value); return false;"/>  
</apex:form>

<apex:detail/> </apex:page>

 

ShamilShamil

I think the best you can do is piggyback on top of the out-of-the-box quote-to-pdf functionality. Based on your explanation I didn't fully understand if that was the case.

 

The following URL will generate a pdf for a quote with ID: 0Q0C0000000Hgjw  and template ID: 0EHC0000000PavI in na8 instance:


https://na8.salesforce.com/quote/quoteTemplateDataViewer.apexp?id=0Q0C0000000Hgjw&headerHeight=10&footerHeight=10&summlid=0EHC0000000PavI#toolbar=1&navpanes=0&zoom=90

 

I don't think quote template Ids can be obtained programmatically, so you may have to store the Quote Template  Name => Id mapping in custom settings or in a custom object.

Your flow would be:

1. User presses on the custom 'Generate PDF' button

2. Your VF controller logic kicks-off and if in this scenario the button shouldn't do anything will display an error message

3. If PDF creation is allowed, user will be displayed a 'Select Template' page where you'd show them their options in a drop-down box, which would be populated from a custom setting/object

4. user selects the template and you redirect them to a URL similar to the following:

https://na8.salesforce.com/quote/quoteTemplateDataViewer.apexp?id=0Q0C0000000Hgjw&headerHeight=10&footerHeight=10&summlid=0EHC0000000PavI#toolbar=1&navpanes=0&zoom=90

 

Hope this helps.

This was selected as the best answer
yvk431yvk431

Hi Starz26, thanks for the reply,  I wanted this on a standard page not  on a visual force page.

 

Shamil, thank you for your solution. I thought there is a way to fetch the Quote template ids rather than to store them in custom setting. Anyways it will do for me. Thanks

 

--yvk

Harshala Shewale (Salesforce)Harshala Shewale (Salesforce)

Hey Shamil,

 

Do you have any idea to download that PDF generated by link and store to Quote Document instead on System ?