Behaviour of xRec

ta5
Member Posts: 1,164
Hi
I have some code on a Table.OnModify trigger. When modifying is done from a form, everything works fine.
However, if the modify trigger is called like "table.modify(true)", rec and xrec in the onmodify trigger are the same.
Is this be design?
Many thanks in advance
Thomas
I have some code on a Table.OnModify trigger. When modifying is done from a form, everything works fine.
However, if the modify trigger is called like "table.modify(true)", rec and xrec in the onmodify trigger are the same.
Is this be design?
Many thanks in advance
Thomas
0
Comments
-
It is not a bug, it just works like that.
I know it is anoying but that is the way it works.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
You can have a look at table 5050 where there is a workaround. This table has a OnModify function that you can call from code as wel.
What you should do is before changing the table store the xrec in a variable. After the modify you can call the function with the new and old record variable.0 -
Thanks for your info about that0
-
Hi,
Table 5050 is very usefully. I just clear about xrec now too
Best Regards,
Klum0 -
There is a sever limitation to the way this is handled in table 5050.
When you implement this using a PARAMETER called xRec, then the User-Defined-Function (not the trigger) called OnModify can reference this parameter, but any function called inside the UDF will still be referencing the (incorrect) xRec.
For Example
OnModify() //trigger
OnModify(xRec)
OnModify(xRec : Record Contact) //user defined function. this work around is shown on table 5050
IF xRec.Name <> Name THEN
MESSAGE('This xRec reference works correctly');
SubFunction();
SubFunct() //sub functions using xRec DO NOT WORK with this workaround, because the PARAMETER xRec is never passed to them!
IF xRec.Name = Name THEN
MESSAGE('This xRec reference incorrectly references the same thing as Rec');
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 320 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