Comparing xrec and rec in nav 2009 sp1 build 29626

ara3n
Member Posts: 9,258
I found this issue with 2009 sp1 finsql.exe with build 29626. xRec and Rec are the same in onmodify trigger when validated from code. It works when manually modified from form.
My code looks at follows.
On purchline onmdify trigger()
if xRec."Direct Unit Cost" <> "Direct Unit Cost" then
Error('Direct Unit Cost value has changed.');
My code in CU
Purchline.get("Document type","No.");
Purchline.validate("direct Unit Cost",23);
Purchline.modify(true);
The error is not triggered.
Anybody knows why?
My code looks at follows.
On purchline onmdify trigger()
if xRec."Direct Unit Cost" <> "Direct Unit Cost" then
Error('Direct Unit Cost value has changed.');
My code in CU
Purchline.get("Document type","No.");
Purchline.validate("direct Unit Cost",23);
Purchline.modify(true);
The error is not triggered.
Anybody knows why?
0
Comments
-
It works on another computer where nav was installed. In the server where this happens the client was installed but nav was started from a local folder.0
-
Hi Rashed
xRec and Rec are the same if not triggered from GUI. Isn't that always the problem? I guess, I have seen this before.
Regards
Thomas0 -
Thomas, you are fully right. See also my blog post Validating Data #5: Data- and XMLports, which in a way touches to same issue.0
-
you are right.
I had removed the code to check xrec and rec.
Was this a recent change in the executables?0 -
No, it has always been like this.
Note: removing the code checking Rec against xRec might bring cause unwanted behaviour in some instances. Be sure you really want to do this. This kind of check:IF xRec."..." <> ".." THEN
in general is done, to only execute code when the user really has changed the value. If the user has retyped a valu (so actually it stays the same) the code will not be executed.0 -
Yes I know this wasn't standard code. I twas my own code that was comparing xRec to Rec.
It's been a while that I have built a mod that compared Rec to xRec. But this should behave the same way if you are entering an order or creating the record through code. The whole point of validating the field is that you are ensuring that same business logic is run.
I'll have to report this MS.0 -
0
-
Good initiative, but I am not sure it really makes sense as probably a lot of code has been written to take this behaviour into account.0
-
This will be an issue going forward especially using webservice.
You want to guarantee that the same logic is run when creating a record manually or through code validating the record and calling
modify(True);0 -
True. Maybe you should provide that info on your msconnect post.0
-
i was stuck about a modification on tracking lines (too hard to explain): the tracking specification was not behaving correctly during the creation of the double reservation entries when entering a transfer order exit...some time later, i've seen standard code that compared xrec and rec, and i suddendly remembered a post talkin about xrec...thanks a lot guys, i did a bad workaround to solve my problem, and now i can fix it correctly! \:D/0
-
Great! And thanx for the feedback as these things are good to know.0
-
If I key a new order from “sales&marketing” , “order processing”, “orders” the system is reflecting the payment discount.
If I key a new order from “sales&marketing” , “sales”, “customer” and here you choose in the customer card menu item “sales” and “order” then hit F3 for insert, the system is not reflecting the correct payment discount.
During debugging I found that inserting a new order this way, xRec was actually equal to another order and this code in the Sales Header.Payment Terms Code OnValidate
would cause unpredictiable results depending on the "bogus" value is xRec.
IF xRec."Document Date"="Document Date" THEN
VALIDATE("Payment Discount %",PaymentTerms."Discount %")
END;
As a work around, I modified the Sales Header on Insert trigger and added this line afer
InsertMode := TRUE;
//
xRec := Rec;
//
I was able to duplicate this in Cronus NAV 2009 sp1. You have to be in the debugger to see that xRec is different the Rec because of the date logic in Cronus.
Any pros or cons on this temporary fix would be appreciated.
JoeJoe0
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