I have a problem with dataport import.....

voodoovoodoo Member Posts: 82
edited 2004-12-20 in Navision Attain
I want to import some records(from txt file - 2 "columns" separated by TAB Name, Address) into Customers table. I was made Dataport(with 2 fields(Name, Address), but without No. because I need automaticly generetaed ID from Customer table(General Ledger->Setup->No. series->Customer)) and nothing happened :(

Why???


misha
misha fka voodoo

Comments

  • eromeineromein Member Posts: 589
    1.) You will need to to INIT the customer record after every imported record.

    2.) You will need to insert the record manually using an INSERT(TRUE)

    3.) After importing the record and filling the fields you will need to do a modify.

    Good luck!
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • voodoovoodoo Member Posts: 82
    Thnx, but I'm a rookie in Navision :oops: , so please can you describe steps above little deeper?

    misha
    misha fka voodoo
  • eromeineromein Member Posts: 589
    Sure,

    If you simply insert a customer record with an empty No. you will create a customer recod with no number.

    This is becaurse in the OnInsert trigger of the customer table is coded that the record should have an unique number. You can call this code by using the insert(true) command.
    Cust.INIT;
    Cust."No." := ''; // Must be empty to let Navision gen. a new number
    Cust.Name := 'Emiel Romein';
    Cust.INSERT(TRUE); // Make sure Navision gen. a new number
    

    You need to do something like this... Another option is:

    [code]
    Cust.INIT;
    Cust."No." := ''; // Must be empty to let Navision gen. a new number
    Cust.INSERT(TRUE); // Make sure Navision gen. a new number

    Cust.Name := 'Emiel Romein';
    Cust.MODIFY;
    [\code]

    So, start you import by emptying the No. field every time you read a recopnd from the file. Then INSERT(TRUE) the record. Import the fields and modify the record.

    Offcouse you understand that I didn't test this all. So I could be way off ;)
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • voodoovoodoo Member Posts: 82
    I put your code into Dataport OnAfterImportRecord() trigger and that's work fine, but instead of your name, i need data from txt file. Sorry, I'm C# programmer and I this is my first day with Navision, so that is the reason because my questions are so low level :(

    misha
    misha fka voodoo
  • eromeineromein Member Posts: 589
    Ok... Well...

    It's a bit more easy then I told you before.

    I did a little test and the following works.

    Just define your dataport like you dide before. Set the fields in the dataport field designer like you do in a "normal" dataport.

    Then code the following in the OnBeforeImportRecord trigger :
    "No." := '';
    INSERT(TRUE);
    

    I've tested it, and it works
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • voodoovoodoo Member Posts: 82
    Thnx,

    I've tested and this is what I need.


    misha
    misha fka voodoo
Sign In or Register to comment.