Check for duplicate value

Hi,

I do an import and I want to check chambre of commerce nummer. Of that value is not already in the database.

This is the field:

IF “”.“Chamber of Commerce no.” THEN

Thank you

Hi Niels,

Not 100% what you want and what you’re trying to do. It will help us answer your questions if they had a bit information.

But do you need to know what you are trying to import. Is it into the customer table, or into a new table. And do you want to validate if there is a customer with this number already before inserting the record?

So I’m really just guessing based on the limited information you have given us.

And how are you doing this import? Using an XMLPort I assume?

Cust.RESET;
Cust.SETRANGE("Chamber of Commerce no.","<Customer>"."Chamber of Commerce no."); 
IF Cust.FINDFIRST THEN

The reason I am not finding against the , but against a new Customer variable, is that I don’t want it to reset the imported record upon finding it. In your case it may not matter as I don’t know what you like to do after the “THEN”.

It’s also important where you are doing this. Which trigger you’re using, which is why it’s important to know you’re importing with an XMLPort (could be done several other ways, including dataports in your case).

If you are not going to abort the import, then it would have wiped anything you would have imported using the XMLport if the customer existed.

A quick advise to get fast and usable answers, is to add just as many details in your question. And always, if there is something you come to think about that you have forgotten to write in your original question, then just add it later.

Happy Friday!

Hi Erik,

thank you for your answare.

Yes, I am using a xml port and I import an xml file. And if in the file there is a chambre of commerce number that match the chambre number in the database then the import has to be cancelled.

But the problem of your solution is that it always return the message that there is a duplicate number

That’s most likely because you are checking against the value you just imported, or that you XMLPort is set to automatically update and create new records. Or not using the code in my example.
You need to disable this first setup of the XMLport, and then handle updates via code, if you want to manage the updates based on the your coded conditions.