nverma wrote:
Solved!
// - ADD Start
// Forces the GLEntry to display data where posting data is between Jan 1st 2011 to current date
ReferenceDate := 010111D;
GLEntry.SETFILTER("Posting Date", '%1..%2',ReferenceDate,TODAY);
// - ADD End
Cost Center - OnAfterGetRecord()
//- ADD Start
// Filters on the Cost Center Code and if it is not found in the GLEntry, then it skips it
GLEntry.SETRANGE("Cost Center Code", "Cost Center".Code);
IF NOT GLEntry.FINDSET THEN
REPEAT
CurrReport.SKIP;
UNTIL GLEntry.NEXT=0;
//- ADD End
Good first step, but as a final solution that's not good at all.
Don't use FINDSET, use ISEMPTY. You don't need to actually loop through the G/L Entry records, all you need to know is whether records exist, like this:
GLEntry.SETRANGE("Cost Center Code", "Cost Center".Code);
IF GLEntry.ISEMPTY THEN
CurrReport.SKIP;
You could also add a G/L Entry dataitem, link it through the cost center code, and turn on the cost center dataitem's PrintOnlyIfDetail property, and you wouldn't need to add any programming at all.