Question about a SETRANGE

sandmansandman Member Posts: 20
This was extracted from codeunit 5400....

Item.SETRANGE("Date Filter",0D,NewItem.GETRANGEMAX("Date Filter"));

I can't get my head around this one! I understand its preparing the "Date Filter" for the following CALCFIELD based on day 1 to.... and this is what I dont understand. What is NewItem.GETRANGEMAX("Date Filter") going to return?

Thanks

Comments

  • kapamaroukapamarou Member Posts: 1,152
    For a filter like 01/01/10..31/01/10 it will return 31/01/10
  • Alex_ChowAlex_Chow Member Posts: 5,063
    Have you looked at the GETRANGEMAX function in the help? It gives a very detailed explanation there.
  • sandmansandman Member Posts: 20
    I know what the GETRANGEMAX function does, I just don't understand what value it's going to return since there is no date filter set at this point on the NewItem record variable... I think... see the code below

    From what I understand, the "Date Filter" of var Item is set via the first SETRANGE but never is it set for var NewItem... So what Max date is it trying to find in NewItem on the last line?

    Or am i not understanding this correctly?

    Item.COPY(NewItem);

    Available := 0;

    IF Item."Include Inventory" THEN
    Item.CALCFIELDS(Inventory);

    IF CalcAvailable THEN BEGIN

    Item.SETRANGE("Date Filter",0D,PlannedOrderReceiptDate);

    Item.CALCFIELDS(
    "Qty. on Sales Order",
    "Qty. on Kit Sales Lines",
    "Scheduled Need (Qty.)",
    "Trans. Ord. Shipment (Qty.)",
    "Qty. on Service Order");
    InitialQtyAvailable :=
    Item.Inventory -
    Item."Qty. on Sales Order" -
    Item."Qty. on Kit Sales Lines" -
    Item."Scheduled Need (Qty.)" -
    Item."Trans. Ord. Shipment (Qty.)" -
    Item."Qty. on Service Order" -
    ExtraNetNeed;

    Item.SETRANGE("Date Filter",0D,NewItem.GETRANGEMAX("Date Filter"));
  • kitikkitik Member Posts: 230
    If the user has defined a flow filter for the Date filter field on the Item table, it will return the rangemax of that filter.

    Salut!
    Laura Nicolàs
    Author of the book Implementing Dynamics NAV 2013
    Cursos Dynamics NAV (spanish) : http://clipdynamics.com/ - A new lesson released every day.
  • sandmansandman Member Posts: 20
    The control that's using this code, where it's interesting me is, the "Availability" amount on the "Item information" frame on the "Orders" form so, there's no user input at this point to specify a date.
  • kitikkitik Member Posts: 230
    Right, it's not an user filter.
    It's using the "Shipment Date" or "Planned Delivery Date" or "Planned Shipment Date" of the sales line. I didn't do a deep test so don't know which one exactly.

    Salut!
    Laura Nicolàs
    Author of the book Implementing Dynamics NAV 2013
    Cursos Dynamics NAV (spanish) : http://clipdynamics.com/ - A new lesson released every day.
  • sandmansandman Member Posts: 20
    What you are saying Kitik makes sense but how do i find out which it is?

    Also, I looked a little deeper (or less deep actually) and found that "Item" record var is being assigned a "Date Filter" before the call to codeunit 5400.

    Item.SETRANGE("Date Filter",0D,0D);

    Now, is that filter passed on the "NewItem" record var when it is copied on the first line of the codeunit? And if so, would that mean that the "Date Filter" on the line that im trying to understand (see below) would be set from 0D to 0D? :?

    Item.SETRANGE("Date FIlter", 0D, NewItem.GETRANGEMAX("Date Filter""));

    Thanks
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    COPY Function (RECORD)

    Copies a record from a C/SIDE table. All filters, marks, and keys are included in the copy.
    "Money is likewise the greatest chance and the greatest scourge of mankind."
Sign In or Register to comment.