all i want is the total balance of inventory before and after the date filter (if there is one provied)Here is my code:
Item - OnAfterGetRecord()
IF DateFilter <> ‘’ THEN BEGIN
SETRANGE(“Date Filter”,0D,GETRANGEMIN(“Date Filter”) - 1);//before datefilter
CALCFIELDS(Inventory);
openBAL := Inventory;
SETRANGE(“Date Filter”,GETRANGEMAX(“Date Filter”) + 1,01019999D);//after datefilter
CALCFIELDS(Inventory);
closeBAL := Inventory;
SETFILTER(“Date Filter”,DateFilter);
END;
All it keeps giving me is the total Inventory for both the openBAL and CloseBAL. I know i am doing something wrong cause ive seen this done in many other places. Can someone please point out my mistake ?
because Datefilter is in text format, it comes from Item.GETFILTER(“Date Filter”), notice the condition if dateflter <> ‘’ then, and GETRANGEMAX / MIN is in format GETRANGEMIN(Field). not GETRANGEMIN(Variable).
The problem is just that GETRANGEMAX(“Date Filter”) in your code returns the original start date of the filter as you have set the line with the “before datefilter” filter to 0D…FirstDayInFilter. If you after that call the GETRANGEMIN it returns 0D and GETRANGEMAX returns FirstDayInFilter.