Dataport-import-Validate question

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,

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

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

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

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

Hi:) Thank you for your quick response! My dataport is so messy now that I don’t dear to share it… :wink: (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?

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,