Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

import data from table to another

Posted on by 4,818

Hi expert, I want to import the open sales order number from the sales header  table to another table B (sales number only),  if  the same sales order number already exists in B, it will not be imported. If I write a report with process only, how to accomplish this? Thank you!

*This post is locked for comments

  • Suggested answer
    keoma Profile Picture
    keoma 32,675 on at
    RE: import data from table to another

    hi,

    do the following.

    the report data item:

    DataType Data Source Name
    DataItem Sales Header <Sales Header>
    Column "Document Type" DocType
    Column "No." DocNo

    report properties:

    ProcessingOnly = Yes

    data item "Sales Header" properties:

    DataItemTableView =  WHERE(Document Type=CONST(Order))
    // to get only sales orders
    

    press F9 to open the code editor

    write following code:

    under trigger OnPreReport()
    ---------------------------------
    counter := 0;
    skipCounter := 0;
    
    under trigger OnPostReport()
    ---------------------------------
    MESSAGE('done! \' + FORMAT(counter) + ' sales order nos imported.\' + FORMAT(skipCounter) + ' nos skipped.');
    
    under trigger "Sales Header - OnAfterGetRecord()"
    ----------------------------------------------------------
    local variables:
    Name DataType Subtype
    SalesOrderListLoc Record Sales Order List
    // table "Sales Order List" ist the new table B 
    // with only 1 field "Document No." (Code 20) 
    
    
    ----------------------------------------------------------
    IF NOT SalesOrderListLoc.GET("Sales Header"."No.") THEN BEGIN
     SalesOrderListLoc.INIT;
     SalesOrderListLoc."Document No." := "Sales Header"."No.";
     SalesOrderListLoc.INSERT;
     counter += 1;
    END ELSE
     skipCounter += 1;
    
    used global variables:
    ----------------------------------------------------------
    counter: Integer
    skipCounter: Integer

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at
    RE: import data from table to another

    Did you try anything?

    Please share what you have tried and what problem are you facing.

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