Date Filter in a codeunit

iqbalmad
Member Posts: 180
Hi,
I have a "Date Filter" defined as Flowfilter in a table
Does this line of code work in a codeunit???
SETRANGE("Date Filter",ldateFirstDate,ReportingDate);
if i do the same thing in a report, it works fine..
can any1 tell me y it doesnt work in a codeunit??
I have a "Date Filter" defined as Flowfilter in a table
Does this line of code work in a codeunit???
SETRANGE("Date Filter",ldateFirstDate,ReportingDate);
if i do the same thing in a report, it works fine..
can any1 tell me y it doesnt work in a codeunit??
0
Comments
-
Can you show us the code?
Have you debugged your code to see the values?
It should work...0 -
in my table > i have a field Forecast which is a sum of Total Costin Job Budget Entry.
in the codeunit, i use the Date Filter which is a flowfilter, to calculate the sum between two dates.
Below are the codes..
WITH lGenProdPostGrp DO BEGIN
SETRANGE("Job Filter",pJob."No.");
//first date of the month
lintMonth := DATE2DMY(ReportingDate ,2);
lintYear := DATE2DMY(ReportingDate ,3);
IF lintMonth < 10 THEN
ltxtMonth := '0'+FORMAT(lintMonth)
ELSE
ltxtMonth := FORMAT(lintMonth);
EVALUATE(ldateFirstDate,'01'+ ltxtMonth + FORMAT(lintYear));
IF ReportingDate <> 0D THEN
SETRANGE("Date Filter",ldateFirstDate,ReportingDate);0 -
You can get the first date of the month by using:
MyDate := CALCDATE('-CM',ReportingDate);
Does your filter get the values you specify?
Have you included the date field in the formula of the flowfield?
Also do you call CALCFIELDS after applying the filters?0 -
Use for the calculating of the first day of month the calcdate function
MyDateFilter := calcdate('<-CM>',ReportingDate);
use here the '<' and the '>'. So your source works also on other systems with other languages. Because the '<' '>' defines the NAV Standard source.
Your FlowField would be calculated, if you calcfield is also after setting the filter.YourTable.setrange("Date Filter",MyDateFilter); //or setrange("Date Filter",calcdate('<-CM>',ReportingDate)); if YourTable.find('-') then YourTable.calcfields(YourFlowField);
RegardsDo you make it right, it works too!0 -
i jus changed my codes to
WITH lGenProdPostGrp DO BEGIN
SETRANGE("Job Filter",pJob."No.");
IF ReportingDate <> 0D THEN
SETRANGE("Date Filter",CALCDATE('<-CM>',ReportingDate),ReportingDate);
and miraculously :-) it worked..
Thanks guys0
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