Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Uploading Data

Posted on by 3,027

Hi

  I am trying these 2 records. Only last record is getting uplaoded. I am uploading using .csv file. In Code i have written Lines := Lines + 10000 . I am using table 81.

01/01/2018 5000
10/01/2018 20000

Thanks

*This post is locked for comments

  • Verified answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Uploading Data

    I don't know how your dataport is designed, but you can also use this technique:

    Declare a global variable recGenJournalLine that point to Table 81.

    "OnBeforeImportRecord()":

    CLEAR("Gen. Journal Line");

    "OnAfterImportRecord()":

    CLEAR(recGenJournalLine); // clear the global variable

    recGenJournalLine."Journal Template Name" := "Journal Template Name";

    recGenJournalLine."Journal Batch Name" := "Journal Batch Name";

    recGenJournalLine.SetUpNewLine(); // Function used in the table 81 to setup anew record

    recGenJournalLine."Line No." := "Line No."; // you can also do a find('+') on the table to find the last line no. and then add 10000.

    recGenJournalLine.VALIDATE("Field1","Field1");

    recGenJournalLine.VALIDATE("Field2","Field2");

    ...

    recGenJournalLine.INSERT(TRUE);

  • Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Uploading Data

    In the OnBeforeImport, add this line:

    CLEAR("Gen. Journal Line");

  • jsshivalik Profile Picture
    jsshivalik 3,027 on at
    RE: Uploading Data

    Hi

      After writing the below code it displays all records but data if of first record in all the records

    Gen. Journal Line - OnAfterImportRecord()
    "Journal Template Name" := 'GENERAL';
    "Journal Batch Name" := 'DEFAULT';
    "Source Code":='GENJNL';
    SETRANGE("Journal Template Name",'GENERAL');

    SETRANGE("Journal Batch Name",'DEFAULT');
    IF "Gen. Journal Line".FINDLAST THEN
    "Line No." := "Line No." + 10000
    ELSE
    "Line No." := 10000;

    Thanks

  • Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Uploading Data

    The problem couod be related to the Line No. initialization. It seems that it's not updated, so you have only the latest key.  In the OnAfterInsert assign the "Line No." by using a local variable to table 81, execute a FINDLAST and read its Line No. Something like:

    GenJournalLine.SETRANGE("Journal Template Name",'GENERAL');

    GenJournalLine.SETRANGE("Journal Batch Name",'DEFAULT');

    if GenJournalLine.FINDLAST THEN

     "Line No." := GenJournalLine."Line No." + 10000

    else

     "Line No." := 10000;

  • jsshivalik Profile Picture
    jsshivalik 3,027 on at
    RE: Uploading Data

    Hi

      Below is the code

    Gen. Journal Line - OnAfterImportRecord()
    "Journal Template Name":='GENERAL';
    "Journal Batch Name":='Default';

    "Line No.":="Line No."+10000;

  • Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Uploading Data

    Are you using an XMLPort? Please give us more details on your code.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans