How to set up data checks and data processings in NAV mappings
This article applies to all import cases, whether the original message was received as an XML file, as an EDIFACT file and so on. The goals of the checks and processings are to determine if all of the required data has been transferred in the message (and if that’s not the case, stop the processing), if all necessary data in the local NAV system can be found (customer, vendors, items etc.) and that all data that has been transferred is also valid (are the prices that were sent for this article correct? Or are they outdated?). For all these checks and processings you need to use a NAV type mapping because any data manipulation can only be done in a NAV type mapping.
The first possibility is the command “TESTFIELD”. When you create a new mapping line, set the Type to “Command” and the Command Type to “TESTFIELD”. The compare type often used is “Not Blank” which checks if a field contains a value or not. This is useful for external item numbers or GTIN numbers when processing orders – the number you don’t have cannot be translated to the internal NAV item no. The same applies to the customer and vendor numbers. When you use a value translation for the contact types and a cross reference to get the customers and vendors from the database via a GLN for example, you can use the testfield to check afterwards if the field “Internal No.” in the corresponding EDI Contact has been filled (e.g. the customer was found) and display an error if the field is empty.
You can use the other compare types like EQUAL / NOT EQUAL and GREATER / LESS to perfom similar checks. To stay at the example of the prices: is the price from the message equal to the one that is set for this item and this customer/vendor in the current period in your database? It’s possible to use a customised error text for every TESTFIELD which will be shown during the (test) conversion and in the processing queue.
When you are receiving an order message and you get the manufacturer’s item number in the message, you might want to identify the item in your database. If you maintain the manufacturer’s item numbers in your item table for example, you can use an NAV mapping to retrieve our item and write it’s number to the EDI Document Line. How do you do this?
At first you write the manufacturer’s item no. to the field “External Item No.” in the table “EDI Document Line in your import mapping. In the following NAV mapping you setup a loop over all EDI Document Lines and indented below the loop you insert a loop over the table “Item”. In the data item link you connect the two tables by the fields that contain the same numbers: “External Item No.” from the table “EDI Document Line” and the one from your database, where you maintain the numbers. If the item table loop finds the appropriate item you can write the item no. to the EDI Document Line, to the field “No.”, in a data mapping line indented below the item table loop.
If you want to check afterwards if there’s really an item no. in your EDI Document Line, you can use the TESTFIELD function on the field “No.” and show an error if it’s empty.
You don’t need to transfer every data from the NAV tables to the EDI Document, when our module creates the records in the NAV tables every OnValidate trigger will be executed and all data pulled from the database automatically will be written to the sales document by the system.