How do I validate during Dataport import?

jfrizelle
Member Posts: 5
Hi,
First post, new to Navision.
I've imported a file of Postcodes using a dataport.
Now I need to import a file of customers, and as I import I want to check that the postcode on the customer record exists in the Postcodes table.
Simple, eh?
But how do I do it???
I've created 'test' tables to mess around with, and here's what I've tried so far...
I've set the TableRelation property on the "Cust Postcode" field to TEST_Postcodes.Postcode, and ValidateTableRelation is set to YES, but when I ran the Dataport it imported customers with non-existant postcodes.
Then I created a record variable and entered code in the OnInsert trigger for the TEST_Customers table as follows :
IF NOT(recTest_Postcodes.GET("Cust Postcode")) THEN
ERROR('Invalid Postcode');
Same thing, still imported customers with invalid data.
](*,) What to do??
Thanks a lot for any help!
J.
First post, new to Navision.
I've imported a file of Postcodes using a dataport.
Now I need to import a file of customers, and as I import I want to check that the postcode on the customer record exists in the Postcodes table.
Simple, eh?
But how do I do it???
I've created 'test' tables to mess around with, and here's what I've tried so far...
I've set the TableRelation property on the "Cust Postcode" field to TEST_Postcodes.Postcode, and ValidateTableRelation is set to YES, but when I ran the Dataport it imported customers with non-existant postcodes.
Then I created a record variable and entered code in the OnInsert trigger for the TEST_Customers table as follows :
IF NOT(recTest_Postcodes.GET("Cust Postcode")) THEN
ERROR('Invalid Postcode');
Same thing, still imported customers with invalid data.
](*,) What to do??
Thanks a lot for any help!
J.
0
Comments
-
I think I would try the same code in the OnAfterImport trigger of your dataport. You can simply do:
recTest_Postcodes.GET("Cust Postcode");
because if there is no such postcode, it will error out all by itself.
By the way, the syntax:IF NOT(recTest_Postcodes.GET("Cust Postcode"))
is not correct. The right way to write the lines you mention is this:IF NOT recTest_Postcodes.GET("Cust Postcode") THEN ERROR('Invalid Postcode');
But again, just the GET should be enough.0 -
Thank you very much Daniel!
I wanted the custom error so that I could specify which customer record had the invalid postcode - it's working fine now.
Rgds,
Jennie.0 -
That is an excellent reason for doing it that way then
Glad you got it to work.
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