# Dataport-import-Validate question

**URL:** <https://www.dynamicsuser.net/t/dataport-import-validate-question/10126>\
**Category:** Developers Forum\
**Created:** [July 14, 2005, 12:45pm UTC](https://www.dynamicsuser.net/t/dataport-import-validate-question/10126 "2005-07-14T12:45:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dina](https://avatars.discourse-cdn.com/v4/letter/d/f0a364/32.png) [@Dina](https://www.dynamicsuser.net/u/Dina)\
**Post date:** [July 14, 2005, 12:45pm UTC](https://www.dynamicsuser.net/t/dataport-import-validate-question/10126/1 "2005-07-14T12:45:33Z")

</div>

Hello to you all who is not yet on holliday[8D] For a klient we need to import items,customers and orders. First we import items and customers - this part is ok. But when we import Sales header and Sales lines the trouble starts… I want Navision to automatically fill in the rest of the fields in the header after importing “Sell-to Customer No.” and setting the “Document Type”. I have tried to make this happen by using CallFieldValidate/ Validate(“Sell-to Customer No.”), but I get thrown an error about values on the sales lines is missing. Therefore I tried to import both header and lines, and then saleshead.setfilter() and call SalesHead.Validate(“Sell-to Customer No.”) from the import of the lines. No errors, but the autofilling didn’t happen anyways… Can you help me do this? TiA,

---

<div class="post-metadata">

**Author:** ![Steffen\_Voel](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@Steffen\_Voel](https://www.dynamicsuser.net/u/Steffen_Voel)\
**Post date:** [July 14, 2005, 2:01pm UTC](https://www.dynamicsuser.net/t/dataport-import-validate-question/10126/2 "2005-07-14T14:01:15Z")

</div>

Hi Birte, It’s a bit difficult to help without your code - so please share it with us [;)]

---

<div class="post-metadata">

**Author:** ![sander7](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@sander7](https://www.dynamicsuser.net/u/sander7)\
**Post date:** [July 14, 2005, 2:01pm UTC](https://www.dynamicsuser.net/t/dataport-import-validate-question/10126/3 "2005-07-14T14:01:57Z")

</div>

Hi Birte, My guess is, that your problem lies in the fact that the customer-info you want to have filled in automatically, have not yet been committed. When you call validate on SalesHeader.“Sell-to Customer No.”, SalesHeader retrieves the Customer-info from the database. regards Alexander

---

<div class="post-metadata">

**Author:** ![Steffen\_Voel](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@Steffen\_Voel](https://www.dynamicsuser.net/u/Steffen_Voel)\
**Post date:** [July 14, 2005, 2:26pm UTC](https://www.dynamicsuser.net/t/dataport-import-validate-question/10126/4 "2005-07-14T14:26:59Z")

</div>

Alexander, Customerdata is available within the scope of the dataport even if it’s uncommitted.

---

<div class="post-metadata">

**Author:** ![sander7](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@sander7](https://www.dynamicsuser.net/u/sander7)\
**Post date:** [July 14, 2005, 2:32pm UTC](https://www.dynamicsuser.net/t/dataport-import-validate-question/10126/5 "2005-07-14T14:32:54Z")

</div>

Steffen, Thanks. Then I learned something new today. I just rembered having a similar problem once, where this was the issue. / Alexander

---

<div class="post-metadata">

**Author:** ![Dina](https://avatars.discourse-cdn.com/v4/letter/d/f0a364/32.png) [@Dina](https://www.dynamicsuser.net/u/Dina)\
**Post date:** [July 14, 2005, 3:17pm UTC](https://www.dynamicsuser.net/t/dataport-import-validate-question/10126/6 "2005-07-14T15:17:27Z")

</div>

Hi:) Thank you for your quick response! My dataport is so messy now that I don’t dear to share it… 😉 (And I’m on my way home for the day… I clean it up tomorrow and post it then) I have read that it can be quite tricky to do a validation of a field during an import, but I guess reading my code will help u help me:) The import happens in 4 operations at this point… First Item, then customer(posting groups and currency code are set), then Sales Header and at last Sales Lines. Since I got the errormessage about fields missing in sales lines when I tried to validate the Customer no on Header import, I tried to do a validation on the field from import of sales lines. Therfore all the nessessary fields on the customer is supposed to be in the database… and information on the lines… (?) Maybe it is better to import both sales header and sales lines in the same dataport? Steffen, do you remember what you did to solve this issue?

---

<div class="post-metadata">

**Author:** ![Dina](https://avatars.discourse-cdn.com/v4/letter/d/f0a364/32.png) [@Dina](https://www.dynamicsuser.net/u/Dina)\
**Post date:** [July 15, 2005, 10:28am UTC](https://www.dynamicsuser.net/t/dataport-import-validate-question/10126/7 "2005-07-15T10:28:27Z")

</div>

Hello again:) I made it work now… Here is the code: ` OBJECT Dataport OrdreHeader { OBJECT-PROPERTIES { Date=15.07.05; Time=12:23:09; Modified=Yes; Version List=; } PROPERTIES { TransactionType=Snapshot; FileName=C:\Ordre.txt; } DATAITEMS { { PROPERTIES { DataItemTable=Table36; OnPreDataItem=BEGIN SETFILTER("Document Type",'1'); END; OnAfterImportRecord=BEGIN //"Currency Code":='NOK'; "Gen. Bus. Posting Group":='KUNDEINN'; "VAT Bus. Posting Group":='KUNDEHîY'; "Posting Date":=WORKDATE; "Document Date":=WORKDATE; "Document Type":=1; VALIDATE("No."); VALIDATE("Document Type"); VALIDATE("Currency Code"); VALIDATE("Sell-to Customer No.","Sell-to Customer No."); "Ship-to Name":="Sell-to Customer Name"; "Sell-to Address":="Ship-to Address"; "Sell-to Address 2":="Ship-to Address 2"; "Sell-to Post Code":="Ship-to Post Code"; "Sell-to City":="Ship-to City"; END; } FIELDS { { ; ;"No." } { ; ;"Sell-to Customer No." } { ; ;"Sell-to Customer Name" } { ; ;"Ship-to Address" } { ; ;"Ship-to Address 2" } { ; ;"Ship-to City" } { ; ;"Your Reference" } { ; ;"Order Date" } { ; ;"Shipment Date" } { ; ;"Currency Code" } } } } REQUESTFORM { PROPERTIES { Width=9020; Height=3410; } CONTROLS { } } CODE { VAR SalesHead@1000000000 : Record 36; NextNo@1000000001 : Integer; BEGIN { "No.","Sell-to Customer No.","Bill-to Name","Bill-to Address","Bill-to Address 2","Bill-to City","Your Reference", "Order Date","Shipment Date","Currency Code" } END. } } ` Have a great summerholliday! Best regards,
