1/ I made a codeunit to modify a record in a table with the function Record.MODIFY(TRUE);
2/ I added a setup in Chang Log setup to track al the modification in this table
3/ When I run the codeunit, nothing is added to the change log table, but when i change manually the record from the table, a change log is added.
Any idea ?
Thanks a lot.
P.S. Navision version 4.00 SP3
My candle burns by both ends, it will not last the night,
But oh my foes and oh my friends, it gives a lovely light
0
Comments
If you need to update the change log also when the record is changed by code you must create your own function based on the changelog management codeunit (see CU 1) and CU for Changelog
REgards
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Just to inform the code looks like that:
But oh my foes and oh my friends, it gives a lovely light
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Nooooooooooooooooooooo
Now people are going to think that this is a good idea. ](*,)
The only way to do it is through code. And I added similar code to the release document CU.
The makes sense in several places in Navision. Maybe it should be moved to how-to, but I don't think it's bad in every scenario.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
You know that, and I know that, and I am sure many other people know that. But I am sure that some people will just see this as a solution, and add it to many code units.
What you are doing (order status) makes sense, since this is something that is directly triggered by a user. (In fact I solve that request normally by allowing the user to manually edit the field, and putting the call to the CU in the validate, but that's off topic).
All I want to say is for developers to consider very carefully before using this Tip
Is it a good idea? Depends on a lot of things:
-Do you really need it?
-Is it useful?
-How do you want to use it? ...
But like you wrote : Consider before using it and if you decide to use it : consider HOW to use it.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Thoughts?
Peter Conijn
-The Learning Network-
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Hello,
If you are talking about the new OnDatabaseInsert and the other OnDatabse... triggers, I wasn't able able to use them. I tried several tests in order to see if they are fired on every insert(true) in the code but didn't succeeded.
I tried for example:
NewItem."No." := 'TESTNO';
NewItem.insert(true);
and OnDatabaseInsert trigger in cu1 i put code to insert some dummy record in a different table but nothing happened. I also put the code ChangLogMgt.LogInsertion(RecRef); which is the same code like the OnGlobalInsert but no Change log entry was registered.
Am I missing something or it's like that ?
10x
Make sure you use the correct function-ID's in codeunit 1 for the triggers, otherwise they are not triggered.
The first time, an Insert/Modify/Delete/Rename is done on a table, NAV launches function "GetDatabaseTableTriggerSetup" in Codeunit 1 that returns for which actions the function must be triggered.
I also did a test with the rename of a card table. And for each record in other tables were the value of that record was changed, the OnModify-trigger was launched!
PS: after you changed something in the code (or setup that is used by that code), you need to re-open the company to reset the objects and setup that was already read.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
The function LogModification is changed, so this is the only way.
Tino Ruijs
Microsoft Dynamics NAV specialist