Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Insert Record

(0) ShareShare
ReportReport
Posted on by 3,051

Hi

 I have added Button on a Form . On click i want to insert a record in another table from that form.

Thanks

*This post is locked for comments

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Insert Record

    Yes, correct. Check that the record in the second table doesn't exists and then perform the INSERT of the new record.

  • jsshivalik Profile Picture
    jsshivalik 3,051 on at
    RE: Insert Record

    Hi

      Thanks . Secondly i first want to check that Document No should not already exists in that table . If not exists Then it should insert

    Thanks

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Insert Record

    I suppose you was using NAV 2013 (this is what is written under your first post). However, for NAV 2009 (Form) you need to create the code under the OnPush event of your button.

  • jsshivalik Profile Picture
    jsshivalik 3,051 on at
    RE: Insert Record

    Hi

      Code is to be written onPush() of Command Button or somewhere other trigger . I am using 2009

    Thanks

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Insert Record

    The record in your page is Rec. In the OnAction trigger you've to create the new record in the second table passing the values from Rec that you need. I don't know your requirements but you can write something like:

    //Check if the record in the second table already exists. If not exists, create the record

    If NOT MySecondTable.GET(...) then

    BEGIN

     MySecondTable.Field1 := Rec.Field1;

     MysecondTable.Field2 := Rec.Field4; //Assign the value you want

     MySecondTable.INSERT;

    END;

  • jsshivalik Profile Picture
    jsshivalik 3,051 on at
    RE: Insert Record

    Hi

      Can u provide sample . I want to write the code in OnAction. I want information from Page to another Custom Table

    Thanks

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Insert Record

    Are you talking about Pages I suppose. In the OnAction of your added button (action), you've to write the code you want (or better, call a function defined in a codeunit that does the work of inserting the record in the other table).

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,387 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans