Passing a date parmeter to a function

Bokk
Member Posts: 138
I'm quite new at Navision and could use some help. I have written a codeunit to summarize some detail journal lines and then export the summary to a flat file. The user needs to be able to enter an end date. Because there is no Request form, I created a small form to enter the date with a command button to process it. In the OnPush trigger of command button, I put code that called a function in my codeunit and passed a ByVal parameter with the date. The codeunit does not seem to like the datatype of the parmeter. An error message indicates the parameter is not a valid date. I did try using the VARIANT2DATE function, but that didn't seem to work.
Should I use a form like this to get the date?
How do I get the function to recognize the date so I can filter on it?
Thanks,
Shelley
Should I use a form like this to get the date?
How do I get the function to recognize the date so I can filter on it?
Thanks,
Shelley
SGM
0
Comments
-
Did you take a look at the variable of the type Dialog ?
I think you can use this one instead of creating an extra form to ask for the date.
Another remark : If you want to create a file, it's better to use a dataport instead of a codeunit
Francis0 -
I hope that this help you you can put it in the code unit.
But I think that using a Data port is more easy program a export/import of values.
Variables
Name DataType Subtype Length
Mov_ Contab Record G/L Entry
Window Dialog
Date1 Date
date2 Date
//Ask for date
Window.OPEN ('Insert Min Data filter #1#######'+
'Insert Max Data Filter #2#######',Date1,date2);
Window.INPUT(1,Date1);
Window.INPUT(2,date2);
Window.CLOSE;
//control filters
IF(date2 > Date1) THEN ERROR ('Error');
IF((Date1 =0D) AND (date2=0D)) THEN ERROR('Error');
//aplicate filters
"Mov_ Contab".RESET;
"Mov_ Contab".INIT;
IF(Date1<>0D) AND (date2<>0D) THEN
BEGIN
"Mov_ Contab".SETFILTER("Mov_ Contab"."Posting Date",'%1..%2',Date1,date2);
END
ELSE
BEGIN
IF(Date1<>0D) THEN "Mov_ Contab".SETFILTER("Mov_ Contab"."Posting Date",'%1',Date1);
IF(date2<>0D) THEN "Mov_ Contab".SETFILTER("Mov_ Contab"."Posting Date",'%1',date2);
END;
//....
MESSAGE("Mov_ Contab".GETFILTERS);
Bye
PD: Sorry my English is aufulSònia Vives Rosich0 -
I was a bit unclear. I want to send the date (as a filter) into a codeunit where I summarize my detail journal lines, then I do call a dataport to create the flat file.
I will try the dialog window and see if I can get the date that way.
Thank you very much!SGM0
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