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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Cannot insert record into custom table

(0) ShareShare
ReportReport
Posted on by

Hi,

I have created a simple table to store the errors during validation of a file. I am able to insert records in the table when I run it. But when I try to do it through code, nothing happens and I do not get any error either.

Same with the delete, I cannot delete records through code.

I am using simple code as below 

MyTable.INIT; 

MyTable.No := 1;

MyTable.Error := 'Error Occurred';

MyTable.INSERT;

Any idea what the issue might be? Any help will be appreciated.

Thanks,

Aparna

*This post is locked for comments

I have the same question (0)
  • Brad_P Profile Picture
    1,549 on at

    Is the Temporary property of the MyTable declaration set to true? Are you certain that the code is executing?

  • Tina Menezes Profile Picture
    2,582 on at

    Hi,

    Can you debug your code and check if it shows any error?

  • Suggested answer
    Amol Salvi Profile Picture
    18,698 on at

    On which trigger the code is written ? Is it on any action button  ??

  • ManishS Profile Picture
    86 on at

    Can you please share the actual code written.

    One thing which I think is that you are overwriting the table with a single record and not incrementing the No. field.

  • Suggested answer
    Zaid Tariq Profile Picture
    2,274 on at

    Hi,

    - Make sure the code is written in the OnRun Trigger.

    - Make sure you are using a valid licence.

  • Suggested answer
    Suresh Kulla Profile Picture
    50,243 Super User 2025 Season 2 on at

    Try to send us the complete code, where you have this code and when are you doing it ?

  • Community Member Profile Picture
    on at

    The code is in the OnPreXMLPort trigger. It is for validation of a file before it is imported as transfer order.

  • Community Member Profile Picture
    on at

    It is a simple insert code, there are currently no records in the table. When it did not insert any records through my validation routine, so I just tried the code below and it does not do anything. The table variable is not marked as temporary.

    MyTable.INIT;

    MyTable.No := 1;

    MyTable.Error := 'Error Occurred';

    MyTable.INSERT;

  • Suggested answer
    Suresh Kulla Profile Picture
    50,243 Super User 2025 Season 2 on at

    Are you getting any error ? Try adding a MESSAGE BOX after insert and check if you get the message ?

  • Community Member Profile Picture
    on at

    I am not getting any error. Also, I found out that the table is being treated as a temporary table, although I have not set it as temporary. I can use it within the trigger but the data is gone once I get out of it.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans