Hi there,
I'm beginning to work as a Navision Developer.
I just finish my classroom training, but haven't yet taken my exams.
There is plenty of work here and my colleagues are already giving me stuff to work on. Therefore, please excuse my poor knowledge on developing in C/AL.
They asked me to create a routine that would change the date on a field of a table.
I thought I could use a processing only report to go to every record of that table and change that field's date. I need to change it to 06-07-2007.
I created a new data item for that table. And placed this code on the onAfterGetRecord() trigger :
tablename.field := today
Who do I change this to put the date I want (06-07-2007)?
Navision does not accept this kind of data, saying "one of the operators contains an invalid data type".
I understand that 06-07-2007 should be of the date data type.
How can I do this?
Thanks and sorry for my ignorence. ](*,)
Regards.
EDIT: should it be like:
tablename.field := 060707D
Answers
If you would like to make it the same date as today, I would write:
The "VALIDATE" makes sure that your code behind the OnValidate trigger is executed as well.
It's obvious that the "field" if of the datatype TODAY.
If you want to change your date to 06/07/07, then you could write:
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
This really helped. I bought "Programming Microsoft Dynamics NAV" by David Studebaker, but I haven't had time to study it yet. I wish I had more time.
Another question related to the date data type:
They also asked me to only change the date field (to 06-07-07) of the records that had the year of 2007 on another field of the same table.
I used this, but then again had the same problem: 'invalid data type".
(If I change the yearfield to integer and remove the quotes from 2007, it works).
What do I do to be able to use 2007 as the year?
Thanks!
Is the answer 2007Y, table.SETRANGE(yearfield, 2007D);? yearfield is a date data type field.
If you explain how the date data type works that would be nice. I don't understand the date format 010101D <-- this I get, 01/01/01, D = stands for day.
Add the field you want to filter and put 010107..123107
Or does it have to be with code?
http://www.BiloBeauty.com
http://www.autismspeaks.org
'2007'
Nav you will find usually has several ways of achiving a goal. which I like.
You could also..
http://www.BiloBeauty.com
http://www.autismspeaks.org