How to SETFILTER by smallest order date

Knaaabis
Member Posts: 7
I need to setfilter by MIN Production ending date like this:
ProductionOrderLine.SETFILTER(ProductionOrderLine."Ending Date",???)
ProductionOrderLine.SETFILTER(ProductionOrderLine."Ending Date",???)
0
Comments
-
you need to get the minimum value of ending date, and THEN you can use it to filter the table...really strange request, imho
prodorderline.setcurrentkey([a key that begins with ending date field]);
prodorderline.findfirst;
mindate := prodorderline."ending date";
clear(prodorderline);
prodorderline.setrange("ending date",mindate);0 -
I haven't get right result... I will show you all code and maybe you integrate your code inside.
ProductionOrderLine.RESET;
ProductionOrderLine.SETCURRENTKEY(Status,"Item No.","Location Code");
ProductionOrderLine.SETFILTER(Status,'%1..%2',ProductionOrderLine.Status::Planned,ProductionOrderLine.Status::Released);
ProductionOrderLine.SETFILTER(ProductionOrderLine.Quantity,'>0');
ProductionOrderLine.SETRANGE("Item No.",Item."No.");
ProductionOrderLine.SETRANGE("Location Code", "Sales Line"."Location Code");
IF NOT ProductionOrderLine.FINDFIRST THEN
CLEAR(ProductionOrderLine);
0 -
You have to use a key which starts with ending date in SETCURRENTKEY0
-
Like this?
ProductionOrderLine.RESET;
ProductionOrderLine.SETCURRENTKEY(Status,"Item No.","Location Code","Ending Date");
...
but what next?0 -
like this
ProductionOrderLine.SETCURRENTKEY("Ending Date",Status,"Item No.","Location Code");
0 -
And what next?0
-
prodorderline.findfirst;
mindate := prodorderline."ending date";
mindate date will have smallest ending date0 -
Doesn't work... Please integreate in full code.
In which place will be this?
prodorderline.findfirst;
mindate := prodorderline."ending date";
That is full code.
ProductionOrderLine.RESET;
ProductionOrderLine.SETCURRENTKEY("Ending Date",Status,"Item No.","Location Code");
ProductionOrderLine.SETFILTER(Status,'%1..%2',ProductionOrderLine.Status::Planned,ProductionOrderLine.Status::Released);
ProductionOrderLine.SETFILTER(ProductionOrderLine.Quantity,'>0');
ProductionOrderLine.SETRANGE("Item No.",Item."No.");
ProductionOrderLine.SETRANGE("Location Code", "Sales Line"."Location Code");
IF NOT ProductionOrderLine.FINDFIRST THEN
CLEAR(ProductionOrderLine);
0 -
IF NOT ProductionOrderLine.FINDFIRST THEN
CLEAR(ProductionOrderLine)
ELSE
mindate := prodorderline."ending date";
Is it a report or where do you need minimum ending date?0 -
It find date, but that isn't Min date - it's first date in table.
For example - I have data in table like this:
......18.12.15
......19.11.15
......03.12.15
Code find date 18.12.15, but should be 19.11.150 -
did you add above code after
ProductionOrderLine.RESET;
ProductionOrderLine.SETCURRENTKEY("Ending Date",Status,"Item No.","Location Code");
ProductionOrderLine.SETFILTER(Status,'%1..%2',ProductionOrderLine.Status::Planned,ProductionOrderLine.Status::Released);
ProductionOrderLine.SETFILTER(ProductionOrderLine.Quantity,'>0');
ProductionOrderLine.SETRANGE("Item No.",Item."No.");
ProductionOrderLine.SETRANGE("Location Code", "Sales Line"."Location Code");0 -
Full Code:
ProductionOrderLine.RESET;
ProductionOrderLine.SETCURRENTKEY("Ending Date",Status,"Item No.","Location Code");
ProductionOrderLine.SETFILTER(Status,'%1..%2',ProductionOrderLine.Status::Planned,ProductionOrderLine.Status::Released);
ProductionOrderLine.SETFILTER(ProductionOrderLine.Quantity,'>0');
ProductionOrderLine.SETRANGE("Item No.",Item."No.");
ProductionOrderLine.SETRANGE("Location Code", "Sales Line"."Location Code");
IF NOT ProductionOrderLine.FINDFIRST THEN
CLEAR(ProductionOrderLine)
ELSE
mindate := ProductionOrderLine."Ending Date";
If i add there "Ending Date" (ProductionOrderLine.SETCURRENTKEY("Ending Date",Status,"Item No.","Location Code");), then i get error message:
"The Prod. Order Line table doesn't have an active key that starts with the following field or fields: Ending date, Status, Item No., Location Code."
0 -
Please check whether there is a key already with Ending date or not
if not then create One0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions