Options

Dataport import problem!!!

JTProJTPro Member Posts: 169
Hi all!

I want to import data from external file (.csv) to Post Code table. I want to skip all records that fields Code or City are empty, so I write such code in OnAferImportRecord trigger:
       IF (PC.Code = '') OR (PC.City = '') THEN
            CurrDataport.SKIP;

It seems ok, but when I run my dataport error occured:
"The field cannot be empty. Please enter a value".
I even try the same code in OnBeforeImportRecord, but nothing changed.
I thought that CurrDataport.SKIP omits current processed record and starts new one?
Any idea?

Best regards!!!
Navision Application Version: 4.0SP1
Navision Database Version: 4.0

Comments

  • Options
    kinekine Member Posts: 12,562
    Try to turn off AutoUpdate and AutoInsert on the dataitem and save the record through C/AL code (add line with Insert or Modify as needed)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    themavethemave Member Posts: 1,058
    Why not just do a quick excel edit of the data file and delete the blank records, easier then coding and you are sure what will be imported
  • Options
    swee-kengswee-keng Member Posts: 6
    I also face similiar with the problem, I try to turn off AutoUpdate and AutoSave on the properties and save the record through C/AL code (add line with Insert or Modify as needed).
    But I still get the error for "The field cannot be empty. Please enter a value".
    Anyone can help? ](*,)
  • Options
    dipsydipsy Member Posts: 4
    Even if Post Code is empty it cannot be inserted in table as "Not Blank " Property for Code In Post Code Table is True
  • Options
    swee-kengswee-keng Member Posts: 6
    ya, if I pass some value to post code but still get the error.

    eg. if postcode = '' then
    "Post Code" := addr4
    else
    "Post Code" := postcode;
  • Options
    dipsydipsy Member Posts: 4
    Hi Try using the following code . Tried its working fine for me.

    IF (PCode='') OR (PCity='') THEN
    CurrDataport.SKIP
    ELSE
    BEGIN
    Postcode.Code:=Pcode;
    Postcode.City:=PCity;
    Postcode.INSERT;
    END
    Create the dataport with Pcode and Pcity in field designer.
    Hope it works for you :)
  • Options
    swee-kengswee-keng Member Posts: 6
    ya, it's work fine.
    Thank a lot. :D
Sign In or Register to comment.