Order date within range then set a value

hairyjim
Member Posts: 99
HI all,
Im guessing this is pretty straight forward for some of you experienced developers, however I have a headache trying to figure it out.
I want to run a report and for each record it parses I want to check the order date and if it falls within a date range then set a value in another field.
If "Sales Header"."Order Date" 28/04/07..24/05/07 THEN
Period := P5;
Obviously this does not work.
Anyone help?
Im guessing this is pretty straight forward for some of you experienced developers, however I have a headache trying to figure it out.
I want to run a report and for each record it parses I want to check the order date and if it falls within a date range then set a value in another field.
If "Sales Header"."Order Date" 28/04/07..24/05/07 THEN
Period := P5;
Obviously this does not work.
Anyone help?
Give a man a fish and he will eat for a day, teach a man to fish and he will drink beer allday.
0
Comments
-
put this code in OnAfterGetRecord() Trigger:
yourtable.SETFILTER(datefield,'25/11/02..26/12/03'); if yourtable.find('-') then begin repeat a := 5;// --> fieldtochange := valueyouwant; until yourtable.next = 0; end;
explanation: the first line select all the records within the value you want.
surely you can put a text variable replacing '25/11/02..26/12/03'.
the second line find the first record within the range you selected and after begins a loop that changes the value of all the fields you want to another value. the loop ends with the "until yourtable.next = 0;" line
think at this line like an "EOF"0 -
Create a global record on table Date.
recDate.RESET; recDate.SETCURRENTKEY("Period Type","Period Start"); recDate.SETRANGE("Period Type",recDate."Period Type"::Date); recDate.SETRANGE("Period Start","Sales Header"."Order Date"); recDate.FILTERGROUP(10); recDate.SETFILTER("Period Start",'28/04/07..24/05/07'); // or some other filter IF recDate.FINDFIRST THEN // or FIND('-') Period := P5;
With this you want only the records (there is only 1) of "Order Date" AND the records in your filter. If "Order Date" falls also in the range, I will have 1 record. If it doesn't fall into the range, I WON'T have a record.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
and if you do not want to filter:
If ("Sales Header"."Order Date" >= 280407D) and ("Sales Header"."Order Date" <= 240507D) THEN Period := P5;
0 -
sorry for my post!!!I saw the big big error I wrote... :oops: the code I wrote is right if putted in onpredataitem, otherwise for each record the process will execute the value change for the whole set of lines filtered
:oops: :oops: :oops: :oops: :oops: :oops: :oops: :oops: :oops:0
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