Xrec equals Rec when calling Validate from XMLPort

bob_up
Member Posts: 155
I am inserting records into the sales line table using an XMLPort in NAV2013 R2.
I use the following statement to assign the item code, which is read into the SKU text variable.
Is there someway around this?
I use the following statement to assign the item code, which is read into the SKU text variable.
"Sales Line".Type := "Sales Line".Type::Item; "Sales Line".VALIDATE("No.",SKU);However this fails to execute the following code in the No. - OnValidate() trigger on the "Sales Line" table.
IF "No." <> xRec."No." THEN BEGIN IF Type = Type::Item THEN IF (Quantity <> 0) AND ItemExists(xRec."No.") THEN BEGIN ReserveSalesLine.VerifyChange(Rec,xRec); WhseValidateSourceLine.SalesLineVerifyChange(Rec,xRec); END; GetDefaultBin; AutoAsmToOrder; DeleteItemChargeAssgnt("Document Type","Document No.","Line No."); IF Type = Type::"Charge (Item)" THEN DeleteChargeChargeAssgnt("Document Type","Document No.","Line No."); END;This is because Xrec."No." is the same as Rec."No." when the trigger is called from an XMLport.
Is there someway around this?
0
Comments
-
Have a look here: Validating Data #5: Data- and XMLports0
-
Thank you Luc. That has got me "unstuck".
However, I am left with one problem.
The unit price on the sales line cannot be read directly from the import file. It will need to be calculated. This is because the import file layout includes a total line amount and a quantity but not a unit price. E.g. a quantity of 2 and a line amount of 200 needs to generate a unit price of 100 on the sales line table. The import file layout is not under my control.
So I will need to calculate the unit price and assign it to the "Sales Line"."Unit Price" field. I will then need the validation code on the "Unit Price" field to be executed (to correctly update the various line values) but I cant see how to do this without hitting my original problem again.0 -
I assumed you would be browsing through some more of my posts on validation. Read this one: Validating Data #2: Using VALIDATE - c'tnd.0
-
I did browse your other posts ;-)
However, this one didn't seem to offer any help with my problem.
I thought your original post demonstrated that when you use VALIDATE in an XMLPort in the way shown in Example 1 then xRec and Rec will be the same.0 -
bob_up wrote:I did browse your other posts ;-)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