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)

Table OnInsert Trigger

(0) ShareShare
ReportReport
Posted on by 273

Hi all,

I'm working on NAV 2016 and i have an external application that send data to a NAV Table through an SQL Update.

Whenever a new record is created I want to send an email to some employees as the code below shows.

OnInsert()
Recipients:='roliveira@sameca.com';//
SMTPMailSetup.GET;
SMTPMail.CreateMessage(
'',
'roliveira@sameca.com',
Recipients,
TestMailTitleTxt1,
STRSUBSTNO(
MailBody,
USERID),TRUE);
SMTPMail.Send;


However by what I realize the Trigger OnInsert of the table is not activated.
I was searching and read something about Local OnDataBaseInsert in (CU1)

OnDatabaseInsert (RecRef: RecordRef)

ChangeLogMgt.LogInsertion (RecRef);
IntegrationManagement.OnDatabaseInsert (RecRef); //This one??
OnAfterOnDatabaseInsert (RecRef);



It Calls a CU 5150

IF IsIntegrationRecord (TableID) OR IsIntegrationRecordChild (TableID) THEN BEGIN
   Insert: = TRUE;
   Modify: = TRUE;
   Delete: = TRUE;
   Rename: = TRUE;
END;


....

IsIntegrationRecord (TableID: Integer): Boolean
EXIT (TableID IN
   [DATABASE :: Resource,
   DATABASE :: MYTABLE]); // ??


So what can i do to the code on my table can be executed? Or i shouldn't change these CU's?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    If you write directly on the NAV table via trigger, the OnInsert trigger is not executed (and so every other trigger). The best way to do is publish the table as Web Service and use that WS to insert data. In this way the triggers will be executed.

  • Rikarddo Profile Picture
    273 on at

    Thanks for the tip Stefano

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)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans