Hi All! I can’t understand why such thing happens I’ve got a option-type field in table. Let’s call it FLD. And I’ve created function, that should change the field (it accepts new value): Function: VALIDATE(FLD, NewValue); MODIFY(TRUE); So, the problem is: When I call this function (I call it from a form), I’ve got none created entries in Change Log Entry table. Please explain me what’s the problem with my code.
Ablievn, I assume you have activated the change log and setup the table that your referring to. I’ve done a lot of work with the change log and added new functionality such as mandatory fields and control fields (limits users ability to changed data at field level). I’ve noticed that when you update a record using code an entry is not always created in the change log. Something else to consider is when changing the change log setup, you MUST reopen the database or the changes wont take effect. The database checks the logged tables when you open the database, not every time the OnGlobal triggers are run… I hope this helps you identify the problem. Alex
Hi Alex! I knew about reopening database after changing logging state. And I surely did it. It is not my case. Could you explain me what did you mean >I’ve noticed that when you update a record using code an entry is >not always created in the change log. May be this could help me. Any rules, hints, notes about why entry is not created?
If a user changes a record from a field on a form a change log entry is created, however if you have code which populates a field as a result of an action (a button being pressed) then no change log entry is created. Try this example. Set the change log to log all modifications to the customer table. Reopen the database and open the customer form. Change the first records “Phone No.” to ‘666’. A change log entry will be there for this modification. Now try creating a basic form based on the Customer table. Add one button with code on the OnPush Trigger to change the “Phone No.” to ‘999’ and Modify the record. eg: OnPush() Rec.“Phone No.” := ‘999’; Rec.MODIFY; No change log entry has been created for this change. It is very dissapointing that the change log functionality doesn’t support coded change. A function could be writen a add entries in the log, but you would have to code the calls to this function in many places which isn’t a good idea. I afraid I haven’ a great solution to offer you.
Alex I think we’ve got solution: try to add: currForm.Update; after your lines and you can comment MODIFY; this worked: VALIDATE(FLD, newValue); currForm.Update;
This is only partially solving the problem. When data is updated from within a table, report or codeunit this trigger obviously can not be called. Calling update must call the Onglobal triggers in Codeunit 1, where modify or modify(true) does not.
Yes it’s still unknown what calls OnGlobal triggers from tables, codeunits and report. I thought it could be only MODIFY By the way I could not find the default parameter for currForm.Update in docs. What it accepts by default TRUE or FALSE?
Hi all, from Help on Modify: [Ok :=] Record.MODIFY([RunTrigger]) RunTrigger Data type: boolean This parameter lets you run the C/AL code in the OnModify trigger. To have the system… Enter… Execute the code in the OnModify trigger TRUE Not execute the code in the OnModify trigger FALSE (default) Pelle
I think ablievn is after infomation about Currform.Update. Currform.Update updates the controls on a form, if an argument of TRUE is used the record is saved first before updating the form. If FALSE is used the record is not saved before updating.
Err and it defaults to FALSE.