Dataport - check if record exist??

I have created a dataport that imports from an excel csv file. I am importing to multiple tables (customer, vendor, job). After creating the dtaport, it gave me an error that customer already exisits in the database. So to get past it, I want to do an If statement that would check if the record exist. If it does exist, I wanted to modify the information in the record from the one in excel file. This code didnt work. if rec.Customer.“No.” = xrec.Customer.“No.” then customer.modify(true); Any idea how I can do this check, and the modify the record???

you can’t modify the primary key using MODIFY function … use RENAME function to modify the PK

what is pk?? Sorry, I am new at NAV and this is my first ever dataport. Can you elaborate a little more.

PK = Primary Key

It’s a database term, and a concept that every developer should know about. You should get a book about database design and normalizing, and learn about how data is stored in tables.

often, it’s done like this:

//assignments to keys, e.g.
customer.“no.” := ‘XXX’; //or
vendor.“no.” := ‘YYY’; // and so on


{this is to place your action when it sucessfully inserting new customer no. or new vendor no.}
… // your statements


{this is to placeyour action when it CANNOT insert, means, “No.” is already exist}
… // your statements