web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Insert Record

(0) ShareShare
ReportReport
Posted on by 3,099

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

I have the same question (0)
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 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).

  • jsshivalik Profile Picture
    3,099 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
    37,166 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
    3,099 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
    37,166 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
    3,099 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
    37,166 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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
Saurav.Dhyani Profile Picture

Saurav.Dhyani 2 Super User 2025 Season 2

#1
Alexander Ermakov Profile Picture

Alexander Ermakov 2

#3
RK-25090803-0 Profile Picture

RK-25090803-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans