Calculating Date

BrandlFlo
Member Posts: 4
Hi,
I am an apprentice in the first year and my englisch isn't very good.
I have a database with two fields "Line Status" with Field-Value Option and a field names "Last Modified at".
My problem is, if the "Last Modified at"-Date is older than a few days (for example 16 days) and the Value of "Line Status" is "finished", the Value of "Line Status" shoult set to "closed" automatically and if the "Last Modified at"-Date is older than only for example 14 days (it must be less days than the first days), navision should automatically send an E-Mail to the user.
My second problem is, if i calculate the amount of the days, i have to discount Sunday and Saturday so i calculate working-days.
I have already written a code, but i don't know what i should do. In this code are no error messages occured.
Here is my Code:
For now the code gives me a Message because i can see, if it works.
I hope you can help me.
I am an apprentice in the first year and my englisch isn't very good.
I have a database with two fields "Line Status" with Field-Value Option and a field names "Last Modified at".
My problem is, if the "Last Modified at"-Date is older than a few days (for example 16 days) and the Value of "Line Status" is "finished", the Value of "Line Status" shoult set to "closed" automatically and if the "Last Modified at"-Date is older than only for example 14 days (it must be less days than the first days), navision should automatically send an E-Mail to the user.
My second problem is, if i calculate the amount of the days, i have to discount Sunday and Saturday so i calculate working-days.
I have already written a code, but i don't know what i should do. In this code are no error messages occured.
Here is my Code:
ServiceItemLine.SETRANGE("Line Status"); ServiceItemLine.SETRANGE("Last Modified at"); ServiceItemLine.FIND('-'); IF LineStatus = ServiceItemLine."Line Status"::finished THEN BEGIN REPEAT IF ServiceItemLine."Last Modified at" < (TODAY - 16) THEN BEGIN MESSAGE('Das Datum wurde vor 16 Tagen zuletzt geändert'); END; UNTIL ServiceItemLine.NEXT = 0; END;
For now the code gives me a Message because i can see, if it works.
I hope you can help me.
0
Comments
-
Hi BrandFlo
If I am understanding your problem correctly you want the Line Status to automatically be updated if specific criteria are met. You have 2 basic options here that I can think of. The first would be to create a 'Periodic Activity', probably using a Processing only Report, that a user would run. This would examine each line for your criteria and then update the status accordingly. If you want the routine to run with zero user interaction, i.e. it just happens, then you will need to use an Application server. You would set it to run a codeunit that would periodically check the lines and perform updates.
The second part of the problem, i.e. getting it to ignore Saturday and Sunday will require a bit more work. I think you will have to use the Calendar functionality in NAV to set up your working days and then have your code refer to this to work out when the required number of working days have passed.
If you would like help in structuring either option let me know and I'll dig out some examples for you.
IanRegards
Ian0 -
Hi
thanks for your help.
But the problem with Saturday and Sunday is in solution.If you would like help in structuring either option let me know and I'll dig out some examples for you.
It would be interesting for me.0 -
Hi,
i am ready now.
It is running.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