0

I have one visualforce page called : QuoteDetail.

This page have button called : Generate PDF.

This Generate pdf open up a popup with selection (checkboxes) 1. Remove items with no quantity 2. Show Discount.

In my pdf i have some list of products with it's details, Now, when i set the checkboxes true before generating pdf then Product with 0 quantity can not display (which is my result in pdf) which is true and pdf will show up as expected with No product who have quantity is 0.

Problem is : I have button called - "Save PDF to Quote", When i click on this button the generated pdf will save in Quote as a quote document but it will save with those all product with quantity 0. expected output is i want save pdf in quote document as it generated. in short generated PDF does not have product with quantity 0(which is correct) and save PDF does have product with quantity 0(Which is incorrect).

visualforce page : QuoteDetail

<div id="dialog" style="display:none;">
    <table border="0" width="98%" cellpadding="7">
        <tr>
            <td valign="top">
                <input type="checkbox" name="checkbox_removeitem" id="checkbox_removeitem" /> Remove items with no quantity
                <!--<apex:inputcheckbox value="{!Quote.Remove_items_with_no_quantity__c}" label="Remove items with no quantity" id="checkbox_removeitem"> 

                </apex:inputcheckbox> Remove items with no quantity-->
            </td>
        </tr>
        <tr>
            <td valign="top">
                <input type="checkbox" name="checkbox_includediscount" id="checkbox_includediscount" /> Show Discount
            </td>
        </tr>
        <tr>
            <td valign="top">
                <input type="checkbox" name="checkbox_removepricing" id="checkbox_removepricing" /> Remove Line Item Price
            </td>
        </tr>
        <tr>
            <td valign="top">
                <input type="checkbox" name="checkbox_removeGrandTotalBox" id="checkbox_removeGrandTotalBox" /> Remove Grand Total Box
            </td>
        </tr>

    <tr>
    <td valign="top">
        <apex:commandButton value="Preview PDF" action="{!showPopup}" rerender="tstpopup" onClick="javascript:OpenPDF('{!Quote.Id}');"/>
    </td>
    </tr>
    </table>
</div>

Apex class : with method of save document

public PageReference attachwithquote() {

    PageReference thePDF =  Page.QuotePDF;
    thePDF.getParameters().put('id',(String)this.Quote.Id);
    thePDF.setRedirect(true);


    if(!test.isrunningtest()){
        quotedocument qd = new quotedocument();
        qd.document = thePDF.getContentAsPDF();
        qd.quoteId = this.Quote.Id;
        insert qd;
    }
    PageReference quotePage = new PageReference('/apex/QuoteDetail?id='+ this.Quote.Id);
    quotePage.setRedirect(true);
    return quotePage;
    //return null;
}
  • I don't understand what is exactly the problem. – Martin Lezer Jun 28 '17 at 7:29
  • Apologize for that, let me update my question with more detailing – Nail David Jun 28 '17 at 7:30
  • @MartinLezer, Please see updated question i've tried to explain bit more about my problem – Nail David Jun 28 '17 at 7:46
  • @NailDavid can you remove thePDF.setRedirect(true); in your code and check again. It seems that it is not keeping the state of your variables. – Kevan Jun 28 '17 at 7:56
  • @Kevan Nope, Not working – Nail David Jun 28 '17 at 7:58

Your Answer

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

Browse other questions tagged or ask your own question.