to xRec or not to xRec that is the question.

Hi all, My setup is NT4(SP6a) + SQL7(SP3) + NF2.6E, and i am experiencing the following problem. i have a codeunit in which i declare a recordvariable lets call it rData at one time in this codeunit i do the following. //Field contains the value 0 at this point (checked in debugger) rData.validate(field,value); //Value=2 rData.modify(TRUE); at this time the onModify routine is called in the table rData. But in the onModify trigger when i check rec.field and xrec.field they both contain the value 2. Instead of rec.field containing 2 (current value) and xrec.field containing 0 (previous value). This behaviour only seems to happen whith this particulair table (other tables i have the same checks in them and they same to work fine) so i guess it has to do with the rest of the codeunit. BUT the problem in the onModify trigger should to my knowledge never happen. and xrec should always point to the previous record. Does anyone have a tip or simulair experience. And could help me in my quest to answer the question: to xrec or not to xrec Best regards,

Check the OnModify trigger of rData.field. If it contains a MODIFY xRec becomes Rec.

Hello, I’ve had the same problem some time ago. My conclusion was that if you call the OnModify-Trigger of a table from a codeunit, rec is the same as xRec. My solution was to make a function in the table where I changed the fields i wanted to change (passing these as variables), and then call that function from within the codeunit. In the new function in the table you can call it’s own OnModify-Trigger and then rec and xRec will be different.

Jan, Thats right. I was confused by “…only seems to happen with this particular table…”. xRec and Rec are always the same when called from codeunits like Mario does. Mario, If you can confirm that you do the same trick with other tables AND xRec and Rec are not the same, pease let us know. Willy

Hi Jan, Willy Spot on. it did the trick. i didn’t know this. My statements that it only didn’t work on this particulair table had to do with the fact that this was also one of the only tables i called from a codeunit. Thanx again, and another mystery solved. p.s. Going to implement jan’s proposition.