skip rest of code

hi,

I am using an xml port where you can import customers and linked connections.

And I check for double chambre of commerce number. But apparently The contacts are still importing without customer if there is a double chambre of commerce number. What ofcourse not has to be.

I have this as code:

“”.SETRANGE(“Chamber of Commerce no.”,"".“Chamber of Commerce no.”);
IF “”.COUNT > 1 THEN
ERROR(‘Kamer van koophandel nummer bestaat al’);

But how to skip the rest of the code - if chambre of comerce number is double?

Thank you

Break;

But that doesnt work. Only the statement break is not recognised. I am using nav 2009

this is how I have it:

BEGIN

{
“”.SETFILTER(“No.”, ‘<>%1’, “”.“No.”);
“”.SETRANGE(“Chamber of Commerce no.”,"".“Chamber of Commerce no.”);
IF NOT “”.ISEMPTY THEN
ERROR('Number already exists ');
currXMLport.SKIP;
}

“”.SETRANGE(“Chamber of Commerce no.”,"".“Chamber of Commerce no.”);
IF “”.COUNT > 1 THEN
ERROR(‘Kamer van koophandel nummer bestaat al’);
//currXMLport.IMPORTFILE := FALSE;
//currXMLport.QUIT;

BussinesContactName.SETFILTER(BussinesContactName.“No.”,"".“No.” );
IF BussinesContactName.FINDFIRST THEN;

“”.“Country/Region Code” := ‘NL’;
“”.“Fax No.” := Rec.“Fax No.”;
//loops through all the contacts connected with a company contact
WHILE (LoopCount <> 0) DO
BEGIN

IF “”.ISEMPTY THEN
BREAK;

KlantContact.GET(FirstContact);
KlantContact.VALIDATE(KlantContact.“Company No.”, BussinesContactName.“Contact No.”);
IF KlantContact.Website = TRUE THEN
KlantContact.“E-Mail Verification” := 1
ELSE
KlantContact.“E-Mail Verification” := 0;

KlantContact.MODIFY;
LoopCount := LoopCount - 1;
FirstContact := INCSTR(FirstContact);
END;

“”.“Primary Contact No.” := BussinesContactName.“Contact No.”;
//insert the bank account properties
IF IBAN <> ‘’ THEN BEGIN
CustomerBankAccount.“Customer No.”:= “”.“No.”;
CustomerBankAccount.IBAN := (IBAN);
CustomerBankAccount.“SWIFT Code” := (Swift);

IF STRLEN(CustomerBankAccount.IBAN) >= 10 THEN
CustomerBankAccount.Code := COPYSTR(CustomerBankAccount.IBAN,STRLEN(CustomerBankAccount.IBAN)-9,10);
“”.“Bank Account Code” := CustomerBankAccount.Code;
CustomerBankAccount.INSERT(TRUE);
END;
RecRef.GETTABLE("");

//connect the payment method to the TemplateHeader and update the record:
//rekening
TemplateHeader.SETFILTER(TableID, FORMAT(18));
IF TemplateHeader.Code = ‘KNT-KLANT’ THEN

TemplateHeader.SETFILTER(TemplateHeader.Code,‘REK-KLANT’);

//kontant
IF TemplateHeader.Code = ‘REK-KLANT’ THEN

TemplateHeader.SETFILTER(TemplateHeader.Code,‘KNT-KLANT’ );

//automatische incasso
IF TemplateHeader.Code = ‘BIN-INC-KL’ THEN

TemplateHeader.SETFILTER(TemplateHeader.Code,‘BIN-INC-KL’ );
UpdateRecordTemplate.UpdateRecord(TemplateHeader, RecRef);

MESSAGE(ImportKlantText + ’ ’ + “”.“No.”);
//rekening
END;

Which XML port trigger are you calling this from?

it is xml port 50010 customer. But this is all customised. But the problem is now that contacts are still added in the database. What not have to be

Hi Niels,
I didn’t ask which xmlport it is.

But which trigger you are calling this from. If the above code is called from the OnInitXMLPort or OnPostXMLPort makes a lot of difference.
Or is it from the data triggers?

Ah, it is like this: BedrijfsInformatie - Import::OnAfterInsertRecord()

Then this might be your problem. You have already inserted the records.
Only Aborting (ERROR) can stop it now.
But if you move your code to the Import::OnBeforeInsertRecord instead, then it might work.

ah, I putted the code:

“”.SETRANGE(“Chamber of Commerce no.”,"".“Chamber of Commerce no.”);
IF “”.COUNT > 1 THEN
ERROR(‘Kamer van koophandel nummer bestaat al’);

here in:

OnPreXMLport()

No, this is not the solution. Because now always the number is already in database

I would test that another time if I was you. At least if the value [Chamber of Commerce No] is part of the data you are trying to import. So in you case you are putting a “filter” on an empty value.
The OnPreXMLPort trigger is run BEFORE NAV has started reading the content of the file.

Did you try to move you code to Import::OnBeforeInsertRecord?

Yes, I did that. But that doesnt work. Because you have customer and contacts. But the KVK attribute is in the Customer main node. So contacts will be addes anyway. I have to solved a other way. Like that I search in the xml file for the attribute:

The FIND functioneren will help you.

“”. SETRANGE(“Chamber of Commerce no.”,""." Chamber of Commerce no.");
IF “”.FIND(’-’) THEN

ERROR(‘Kamer van Koophandel nummer bestaat al’);

REPEAT
// insert statements to repeat.

UNTIL NEXT = 0;