I've been trying to figure out how to call the code myself in the dataport
with no luck. I'm not exactly sure how I should use a record reference when
I'm working with a record variable and how to access the xRec version of the
record. I see this code: ChangLogMgt.LogModification(RecRef,xRecRef); but my
hunch is that RecRef and xRecRef are populated automatically somehow by the
.exe. I can't seem to find where they could be populated.
Is this just a bug in Navision that excludes dataport updates from the
changelog?
Is there a way around this to include dataport updates in the ChangeLog? My
dataport code finds the record, updates the fields and calls .MODIFY(TRUE),
but even including true to hit the table triggers doesn't update the
changelog.
Any ideas and help would be greatly appreciated.
Thanks!
> I noticed that when I use a dataport, the Change Log does not get updated.
> The OnGlobalModify trigger in ApplicationManagement doesn't get called.
>
> I've been trying to figure out how to call the code myself in the dataport
> with no luck. I'm not exactly sure how I should use a record reference when
> I'm working with a record variable and how to access the xRec version of the
> record. I see this code: ChangLogMgt.LogModification(RecRef,xRecRef); but my
> hunch is that RecRef and xRecRef are populated automatically somehow by the
> .exe. I can't seem to find where they could be populated.
>
> Is this just a bug in Navision that excludes dataport updates from the
> changelog?
>
It is by design. The ChangeLog routines in Codeunit 1 only got executed when
a user is making a modifications in a form. So if a user updates a field on a
form, the functions in Codeunit 1 are fired, but when the system updates a
field, then it won't.
> Is there a way around this to include dataport updates in the ChangeLog? My
> dataport code finds the record, updates the fields and calls .MODIFY(TRUE),
> but even including true to hit the table triggers doesn't update the
> changelog.
Try this code to execute the ChangeLog code:
RecRef.GETTABLE(Rec);
xRecRef.OPEN(RecRef.NUMBER);
xRecRef.GET(RecRef.RECORDID);
Rec."Your Field" := "Your Value";
Rec.MODIFY;
cduChangeLogManagement.LogModification(RecRef,xRecRef);
Code is taken from this thread:
http://www.mibuso.com/forum/viewtopic.php?t=5733
Regards,
Luc Van Dyck
webmaster http://mibuso.com
I'm not sure if it makes a diffence that I'm using a record variable other
than rec. Here's a bit of my code in the dataport....
IF EmployeeRec.GET("No.") THEN BEGIN
// this is so we can update the changelog ourselves
RecRef.GETTABLE(EmployeeRec);
xRecRef.OPEN(RecRef.NUMBER);
xRecRef.GET(RecRef.RECORDID);
IF FORMAT("First Name") <> '' THEN EmployeeRec."First Name" := "First Name";
IF FORMAT("Middle Name") <> '' THEN EmployeeRec."Middle Name" := "Middle
Name";
IF FORMAT("Last Name") <> '' THEN EmployeeRec."Last Name" := "Last Name";
... this goes on for each field ...
IF FORMAT("First Name") = 'delete' THEN CLEAR(EmployeeRec."First Name");
IF FORMAT("Middle Name") = 'delete' THEN CLEAR(EmployeeRec."Middle Name");
IF FORMAT("Last Name") = 'delete' THEN CLEAR(EmployeeRec."Last Name");
... this also goes on for each field ...
// EmployeeRec.MODIFY;
ChangLogMgt.LogModification(RecRef,xRecRef);
EmployeeRec.MODIFY;
Now I've tried the MODIFY before and after calling LogModification and when
I step through the code xRecRef and RecRef both have the same values. Either
they are both set to the value before the modify or they are set to the
values after the modify. Do I need to lock the table or something to make
this work? That's the only thing I saw in the other post that I thought might
be needed.
Any further help would be greatly appreciated.
I think the line
RecRef.GETTABLE(EmployeeRec);
should be moved immediately before the call to the ChangeLogManagement
codeunit. And that the MODIFY instruction is needed.
Here is some code taken from a live database, where a new field "Status
Credit Limit" is changed, and the changes to this field are logged :
lrrxRecRef.GETTABLE(Rec);
lrrxRecRef.SETPOSITION(Rec.GETPOSITION);
"Status Credit Limit" := "Status Credit Limit"::Released;
CALCFIELDS("Amount excl VAT");
"Released Amount excl VAT" := "Amount excl VAT";
"Released Currency Code" := "Currency Code";
"Released Bill-to Customer No." := "Bill-to Customer No.";
MODIFY;
lrrRecRef.GETTABLE(Rec);
lrrRecRef.SETPOSITION(Rec.GETPOSITION);
lcduChangLogMgt.LogModification(lrrRecRef,lrrxRecRef);
Hope this helps.
Thank you Luc, it works!