function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
springerwaspringerwa 

Force.com Quote/Opportunity Line Item Apex code - how to pass and use integer from field to class

I am using the Simple Quotes app from Force.com along with the improvements suggested in this post Creating Professional PDF Documents with CSS and Visualforce and since our Product Descriptions are sometimes very long I am having difficulty with locked in pagination.

 

The code right now asks you to set a private static Integer (code below)

 

 

//controls how many quote line items are displayed on page 1
private static Integer FIRST_BREAK = 8;
//controls how many quote line items are displayed on subsequent pages
private static Integer SUBSEQ_BREAKS = 10;

public List<Quote_Item__c[]> pageBrokenQuoteItems {get; private set; }

 

and that works for about 30% of our Quotes...however, due to long Product Descriptions it doesn't work for the other 70%.

 

What I would like to do is create 2 fields on the quote line item object (FIRST_BREAK__c and SUBSEQ_BREAKS__c) and default them to 8 and 10 respectively and then have the class read the number from the fields so the user can change the numbers to change the page break where it makes sense.

 

Can someone assist with how to change so these integers are pulled from the record if the user changes them?

 

 

Related Page Break Code:

 

//splits the quote lines into an approximate number of rows that can be 
//displayed per page
private void prepareQuoteLinesForPrinting()
{
pageBrokenQuoteItems = new List<Quote_Item__c[]>();

Quote_Item__c[] pageOfQuotes = new Quote_Item__c[]{};
Integer counter = 0;

boolean firstBreakFound = false;
//boolean setSubSeqBreak = false;
//Integer breakPoint = FIRST_BREAK;

for(Quote_Item__c q : quoteLineItems)
{
if(!firstBreakFound)
{
if(counter < FIRST_BREAK)
{
pageofQuotes.add(q);
counter++;
}
if(counter == FIRST_BREAK)
{
firstBreakFound = true;
counter = 0;
pageBrokenQuoteItems.add(pageOfQuotes);
pageOfQuotes=new Quote_Item__c[]{};
}
}
else
{
if(counter<SUBSEQ_BREAKS)
{
pageofQuotes.add(q);
counter++;
}
if(counter == SUBSEQ_BREAKS)
{
counter = 0;
pageBrokenQuoteItems.add(pageOfQuotes);
pageOfQuotes=new Quote_Item__c[]{};
}
}
}
//if we have finished looping and have some quotes left lets assign them
if(!pageOfQuotes.isEmpty())
pageBrokenQuoteItems.add(pageOfQuotes);
}