Data change register
lodger
Member Posts: 16
Can anyone help.
We use a data change register in 2.4, similiar to that used in 3.7, to track changes to tables. We track an option field on the sales header which works when changed manually from the sales order form. However we also update this option box while running a report but this change is not registered in the DCR. Are there any suggestions how I can make this work, I am calling the dcr from the OnModify trigger within the sales header table.
lodger
We use a data change register in 2.4, similiar to that used in 3.7, to track changes to tables. We track an option field on the sales header which works when changed manually from the sales order form. However we also update this option box while running a report but this change is not registered in the DCR. Are there any suggestions how I can make this work, I am calling the dcr from the OnModify trigger within the sales header table.
lodger
0
Comments
-
I started working with Navision in 1998 but i haven't heard from the 2.4 version.
But maybe the report only does an asignment (like fieldname := value) and not a validateion (like record.validate(fieldname,value)). The asignment only enters a value in the field and doesn't trigger the OnValidate trigger (where the logging code should be).
Hope this helps!
Regards,Now, let's see what we can see.
...
Everybody on-line.
...
Looking good!0 -
Actually, you should not be looking for a Field assignment - Rec.Field := Value - in order to replace it with a VALIDATE statement - Rec.VALIDATE(Field,Value).
You should look for a MODIFY on the Report. That Rec.MODIFY command should then be replaced with Rec.MODIFY(TRUE) which will cause the OnModify trigger of the table to be run and, subsequently, your DCR code to be run.
[edit]
When doing this, take a careful look at the OnModify trigger.
It can happen that the Report is intentionally not running this trigger because there is code in the trigger that shouldn't be executed.Nelson Alberto0 -
Appologies it's version 2.6. I have tried both suggestions and neither work.
The code in the OnPreSection trigger of the report is:
"Sales Header"."Order Status" := "Sales Header"."Order Status"::xxx;
"Sales Header".MODIFY;
The code in the OnModify trigger of sales header table only calls the dcr (dcr.CheckOrder (xRec,Rec);).
Any more suggestions.
lodger0 -
That's exactly what I said!
You have to replace:
"Sales Header".MODIFY;
with:
"Sales Header".MODIFY(TRUE);Nelson Alberto0 -
Hi nelson
I tried it and it doesn't work. Thought I might be missing something so I posted the code. Any reason why it's not working?
lodger0 -
If you are using some self-made module, I can't help you, because I don't know how it works. Look inside your module if there isn't any conditions which will skip register process in some situations...
0 -
First do what neslon suggests, then put this in OnModify but before a call of your function:
MESSAGE('%1\%2',xRec."Order Status", rec."Order Status");
This way you will see what value is in xRec.
I remember that xRec sometimes just wasn't what it should be (old rec). I used following code as first line in OnModify:
xRec.GET(Rec."PK Filed 1",Rec."PK Field 2");
"PK Filed 1" is first field in primary key, "PK Filed 2" is second field in primary key, etc. For "Sales Header" it sholud look like:
Rec.GET(Rec."Document Type",Rec."No.");®obi
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯0 -
Two items...:
1) My experience has been that whenever the 'current record' is not the base record of a form (i.e. is not 'Rec' in some form), then xRec does not seem to be 'a copy of the record as originally read from the db', but rather seems to be just a copy of the record. Therefore, any mods to the record are 'instantly' reflected in xRec, and table trigger code that depends on the differences between Rec and xRec will not work.
2) Navision code uses the following pattern to log changes to a record, whenever a 'loggable' change is made outside the context of a form (see for example codeunit 103 - Cust. Entry-Edit)://pseudocode... save currRec in oldRec; modify currRec; call LogModification with currRec, oldRec;
So, in your report trigger, you might write:oldHdr := "Sales Header"; "Sales Header"."Order Status" := "Sales Header"."Order Status"::xxx; "Sales Header".MODIFY; dcr.CheckOrder(oldHdr,"Sales Header");
0 -
fb, this also looks as good idea ! The code in OnModify is still needed to log changes that are made manually through forms and the programmer must be careful in code when to use MODIFY(TRUE) and when MODIFY(FALSE).®obi
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯0 -
Thanks fb and RobertMo
I used fb's suggestion as it keeps the code in the report and it works GREAT!
I created 2 global variables
oldHdr, Record, Sales Header and
dcr, Record, Data Change Register
Is this correct? It must be as it works and doesn't appear to affect anything else.
Thanks again for the help.
lodger0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 328 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
