Hello Dynamics Community.
I am actually customizing a report where I need to get the last posting date of item in the item ledger entry table whether the entry type is sale, purchase, positive adjmt, negative adjmt, etc....
So my dataitem is the Item Ledger Entry table and I have 3 colums: Item No., Posting Date and Entry Type.
I have defined PostingDate as variable date in C/AL globals.
On PreReport trigger i have inserted this code:
"Item Ledger Entry".SETCURRENTKEY("Item No.","Posting Date","Entry Type");
"Item Ledger Entry".SETRANGE("Item No.","Item Ledger Entry"."Item No.");
"Item Ledger Entry".SETRANGE("Entry Type","Item Ledger Entry"."Entry Type"::" ");
IF "Item Ledger Entry".FINDLAST THEN
 PostingDate:= "Item Ledger Entry"."Posting Date";
But my report is showing all items with their all posting dates. It is not taking the last posting date of an item. It is taking all the posting dates. For example, for an item No. 1100, it has entry type and posting dates as Consumption (9/8/2019), Consumption (9/7/2019),Consumption(9/6/2019) and Postive Adjmt (6/1/2018). The report is taking all these. It is not taking only last entry type and posting date that is Consumption (9/8/2019).
Grateful if someone tell me how can I achieve the following above?
Thanks to help me.