Rec and xRec same when updating through RECORDREF
robertderoos
Member Posts: 10
I have a simple function
which applies a change to a field in the sales line to other sales lines using RECORDREF and FIELDREF.
When updating through my function no changes are detected and through debugging I found out that Rec and xRec are the same (both with the updated value).
It makes no difference [-X if I modify through RecRefUpdateRec.MODIFY(TRUE) or through UpdateRec.MODIFY(TRUE).
I can add the code from the OnModify trigger to the function but then every time someone changes the code in the OnModify trigger he or she must do this also in this function. This mean more documentation, etc., etc.
Does anyone has a solution for this problem.
I'm developing in 5.0, is it a bug? :bug:
Thanks,
Robert
ChangeSublineField(NewRec : Record "Sales Line";FieldNo : Integer)
SetTargetRange(UpdateRec,NewRec);
RecRefNewRec.GETTABLE(NewRec);
FieldRefNewRec := RecRefNewRec.FIELD(FieldNo);
IF UpdateRec.FINDSET THEN REPEAT
RecRefUpdateRec.GETTABLE(UpdateRec);
FieldRefUpdateRec := RecRefUpdateRec.FIELD(FieldNo);
FieldRefUpdateRec.VALIDATE(FieldRefNewRec.VALUE);
// RecRefUpdateRec.MODIFY(TRUE);
RecRefUpdateRec.SETTABLE(UpdateRec);
UpdateRec.MODIFY(TRUE);
UNTIL UpdateRec.NEXT = 0;
In the OnModify trigger of Sales Line there is code which compares Rec values with xRec values in order to notice a change.When updating through my function no changes are detected and through debugging I found out that Rec and xRec are the same (both with the updated value).
It makes no difference [-X if I modify through RecRefUpdateRec.MODIFY(TRUE) or through UpdateRec.MODIFY(TRUE).
I can add the code from the OnModify trigger to the function but then every time someone changes the code in the OnModify trigger he or she must do this also in this function. This mean more documentation, etc., etc.
Does anyone has a solution for this problem.
I'm developing in 5.0, is it a bug? :bug:
Thanks,
Robert
0
Comments
-
Rec and xRec are not always the same in NAV 4.02 too. Doesn't matter if you use recref or not.
In you situation:
Are you sure NewRec and others are defined as var?0 -
What I am used to find is that if you do a MODIFY on a record-variable, both rec and Xrec have the same value. They only have a different value if the modify is launched by a form-SourceTable-record.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Thank you for your replies.
I never knew this, so this could have some serious consequences.
I think :-k we have to move some code to field validation or update functions , like UpdateUnitPrice or UpdateDates.0 -
You can also put some code in a function that accepts 2 records : the new and the old.
In your program, you can run this function yourself with an old version of the record and the version on which you are working. So you need to variables to do this.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
kriki wrote:What I am used to find is that if you do a MODIFY on a record-variable, both rec and Xrec have the same value. They only have a different value if the modify is launched by a form-SourceTable-record.
Correct, and onmodify from header to lines (salesline, etc.) don't always work.0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions