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
0
Comments
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,
...
Everybody on-line.
...
Looking good!
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.
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.
lodger
You have to replace:
"Sales Header".MODIFY;
with:
"Sales Header".MODIFY(TRUE);
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?
lodger
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
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.");
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
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): So, in your report trigger, you might write:
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
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.
lodger