How to delete records through a Dataport


This is my first time posting here, and my second week working with NAV (I’m on 5.0).

From reading through some other similar posts, it looks like you can’t delete records from a dataport. So what would be the best way for me to delete records as needed? Should I add code to the OnDelete() of the table I need to delete the records from, and call that trigger from the dataport?

Thanks in advance!

Why would you want to delete records using a dataport.

Please explain what you are trying to accomplish.

I guess that was worded strangely. I’m still pretty new to NAV [:$]

I am having to import updates to an items table, and the way the number system is, there tends to be some duplicates created. I was building in a way to delete those duplicate records that were not needed.

I actually have it doing what they want it to do now, I was just missing the COMMIT.

You shouldn’t need to manually do a COMMIT in the dataport. It may be working, but your code is probably very wrong (don’t take that personally). Read the development material which is available on customersource or partnersource, depending on the type of company you are working for. Search the forums for those if you don’t know what they are.

No offense taken. I’m in the learning process, so any advice will be taken.

I’ll take a look at the material you suggested.


Item.“NO.” is a key field, Nav won’t allow duplicates of a key field …that’s why it’s a key.

You can add code to your dataport & use CurrDataport.Skip; when you find a condition that you need to skip a record.

For example you can import your data into Variables and then map them to the standard Nav fields on the OnAfterImportRecord.


IF Item.GET(ImportedItemNo) THEN BEGIN
Item.“No.” := ImportedItemNo;
other fields…
other fields…

So when selecting dataport fields I manually enter ImportedItemNo there
Then the Get looks in the item table to see if it already exists.
If it does it skips that record.

if you search the forum for dataport & variables - you should find other examples.
The Application Designers Guide has a section on Dataports (w1w1adg.pdf) on your product cd.
or downloadable from here:

The code above is great when you are importing new items>

but also Click on the dataitem & view properties - you will see there 3 options.
AutoSave, AutoUpdate,AutoReplace - F1 those to get the help & try to understand what they can do for you.