+ Start a Discussion
domdickdomdick 

Help on question/apex code

Hi,

 

we have custom button that render as PDF for Opportunity with their opportunitylineitems.

Now the user will add another opportunitylineitem on same Opportunity and generate the PDF BUT how can i make sure it does include the one that added recently.

 

ex.

1)Opprtunity with 3 lineitem

2) custom button generate PDF with step 1

3) user add another lineitem on same Opportunity

4) custom button generate PDF with step 3 and not include step 1 (3 lineitems)?? HOW???

 

I would appriciate if someone can help.

 

Many thanks,

 

goabhigogoabhigo

Not clear. Do you want to add the recently added OLI to the PDF? If you have 3 OLIs, now if you add 1 more, the PDF should show 4 OLIs, is that what you want?

domdickdomdick

Not really,

 

If i have 3 OLI, and add 1 more then PDF should show only latest OLIs Not 3 OLIs.

 

goabhigogoabhigo

Is there any field to identify what is latest? Is there any fixed number of OLIs that can be added at a time? If yes then you can sort it and limit the selection to that number.. If you can explain the business requirement of this, it would be great. 

ksanketksanket

Sort it by created date and put LIMIT on in,you problem will be solved.

domdickdomdick

Hi Abhi,

 

let me explain in the current process...

1) Sales people create Opportunity with any number of require OLIs (may be 3 or more....)

2) Sales people click on custom button that generate PDF (that include details of the Opportunity along with OLIs) via VF page.

3) Sales people send the PDF to client for an approval

4) if the client approve the PDF then custom_field value change to 'complete'

 

but later on

 

4) if Sales people add another OLI into same Opportunity then

5) Sales people click on custom button again to generate PDF but i would like to exclude Step (1) as it's been already approved.

 

so I am strugling to produce any solution on controller and VF page. Can you help???

 

Thanks,

 

 

goabhigogoabhigo

Ok, now this is clear. 

 

When approved are you changing status (a picklist or a checkbox) of those OLIs? If not I suggest you do that. So once approved they should not be present in PDF again. Just add a 'where' clause in your query to exclude OLIs that are approved. That should do the work for you.

 

If not clear let me know.

domdickdomdick

The challenge here is...

 

the approval status change on Custom_object__c Object and field called 'Status'

 

So how can reflect the completed status on standard OLI object?

goabhigogoabhigo

How are you sending the PDF? Is it done through code? If yes, then include the logic of updating the Status of OLI in that code. Else ask users to manually update the status.

 

I am surprised why you are not using Quotes for these requirements. I think having different set of QLIs for first quote, different ones for second Quote should fulfill your requirement.