# skip rest of code

**URL:** <https://www.dynamicsuser.net/t/skip-rest-of-code/60374>\
**Category:** Developers Forum\
**Created:** [April 12, 2016, 9:40am UTC](https://www.dynamicsuser.net/t/skip-rest-of-code/60374 "2016-04-12T09:40:41Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![SavantKing](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@SavantKing](https://www.dynamicsuser.net/u/SavantKing)\
**Post date:** [April 12, 2016, 9:40am UTC](https://www.dynamicsuser.net/t/skip-rest-of-code/60374/1 "2016-04-12T09:40:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Cederic1984](https://avatars.discourse-cdn.com/v4/letter/c/59ef9b/32.png) [@Cederic1984](https://www.dynamicsuser.net/u/Cederic1984)\
**Post date:** [April 12, 2016, 11:42am UTC](https://www.dynamicsuser.net/t/skip-rest-of-code/60374/2 "2016-04-12T11:42:28Z")

</div>

Break;

---

<div class="post-metadata">

**Author:** ![SavantKing](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@SavantKing](https://www.dynamicsuser.net/u/SavantKing)\
**Post date:** [April 12, 2016, 12:38pm UTC](https://www.dynamicsuser.net/t/skip-rest-of-code/60374/3 "2016-04-12T12:38:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![SavantKing](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@SavantKing](https://www.dynamicsuser.net/u/SavantKing)\
**Post date:** [April 12, 2016, 12:39pm UTC](https://www.dynamicsuser.net/t/skip-rest-of-code/60374/4 "2016-04-12T12:39:43Z")

</div>

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](https://currXMLport.IMPORTFILE) := FALSE;  
[//currXMLport.QUIT](https://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;

---

<div class="post-metadata">

**Author:** ![admin1](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/admin1/32/7476_2.png) [@admin1](https://www.dynamicsuser.net/u/admin1)\
**Post date:** [April 12, 2016, 1:31pm UTC](https://www.dynamicsuser.net/t/skip-rest-of-code/60374/5 "2016-04-12T13:31:25Z")

</div>

Which XML port trigger are you calling this from?

---

<div class="post-metadata">

**Author:** ![SavantKing](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@SavantKing](https://www.dynamicsuser.net/u/SavantKing)\
**Post date:** [April 12, 2016, 1:32pm UTC](https://www.dynamicsuser.net/t/skip-rest-of-code/60374/6 "2016-04-12T13:32:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![admin1](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/admin1/32/7476_2.png) [@admin1](https://www.dynamicsuser.net/u/admin1)\
**Post date:** [April 12, 2016, 1:42pm UTC](https://www.dynamicsuser.net/t/skip-rest-of-code/60374/7 "2016-04-12T13:42:08Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![SavantKing](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@SavantKing](https://www.dynamicsuser.net/u/SavantKing)\
**Post date:** [April 12, 2016, 1:45pm UTC](https://www.dynamicsuser.net/t/skip-rest-of-code/60374/8 "2016-04-12T13:45:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![admin1](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/admin1/32/7476_2.png) [@admin1](https://www.dynamicsuser.net/u/admin1)\
**Post date:** [April 12, 2016, 1:48pm UTC](https://www.dynamicsuser.net/t/skip-rest-of-code/60374/9 "2016-04-12T13:48:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![SavantKing](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@SavantKing](https://www.dynamicsuser.net/u/SavantKing)\
**Post date:** [April 12, 2016, 1:48pm UTC](https://www.dynamicsuser.net/t/skip-rest-of-code/60374/10 "2016-04-12T13:48:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![admin1](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/admin1/32/7476_2.png) [@admin1](https://www.dynamicsuser.net/u/admin1)\
**Post date:** [April 12, 2016, 1:53pm UTC](https://www.dynamicsuser.net/t/skip-rest-of-code/60374/11 "2016-04-12T13:53:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![admin1](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/admin1/32/7476_2.png) [@admin1](https://www.dynamicsuser.net/u/admin1)\
**Post date:** [April 12, 2016, 4:14pm UTC](https://www.dynamicsuser.net/t/skip-rest-of-code/60374/12 "2016-04-12T16:14:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![SavantKing](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@SavantKing](https://www.dynamicsuser.net/u/SavantKing)\
**Post date:** [April 12, 2016, 4:19pm UTC](https://www.dynamicsuser.net/t/skip-rest-of-code/60374/13 "2016-04-12T16:19:37Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![Cederic1984](https://avatars.discourse-cdn.com/v4/letter/c/59ef9b/32.png) [@Cederic1984](https://www.dynamicsuser.net/u/Cederic1984)\
**Post date:** [April 12, 2016, 6:09pm UTC](https://www.dynamicsuser.net/t/skip-rest-of-code/60374/14 "2016-04-12T18:09:38Z")

</div>

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;
