Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / How to do action after...
Finance forum
Suggested answer

How to do action after inserted record in sysdatabaselog table

Posted on by 118
Hi All,
 
I want to do some action after record inserted in sysdatabaselog table, and currently i try to use oninserted event handler
 
[DataEventHandler(tableStr(SysDataBaseLog), DataEventType::Inserted)]
public static void SysDataBaseLog_onInserted(Common sender, DataEventArgs e)
{
   //action here
}
 
but the event handler could not be triggered
 
Thanks & Regards,
Masha
  • How to do action after inserted record in sysdatabaselog table
    As have already been mentioned in this post the logic around databaselog is a bit different so it's not possible to configure alerts or subscribe to events directly off that table as far as I can tell. I have been able to do a workaround for specific scenarios (only parameter tables, heavy risk of performance issues) using signature log. 
     
    SigSignatureLog table works with alerts and thereby you can also leverage the business event for alerts created. The trick is to configure electronic signature on the tables needed, this link explains it very well:
     
     
    Once the signature is set up then you can configure alerts on the signed records and do whatever you need to do with them. For our specific scenarios where we needed to audit specific tables for changes it resolved it without resorting to custom events or anything else.
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 290,349 Super User 2024 Season 2 on at
    How to do action after inserted record in sysdatabaselog table
    Hi Masha,
     
    As Martin mentioned, database log setup will create SQL triggers on the tables. Using these triggers, the database log is filled in the background. Can you tell the business problem you need to solve with an action after the insert?
  • Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,538 Moderator on at
    How to do action after inserted record in sysdatabaselog table
    Can you give some more information your business problem? I understand you need to trigger some action on insert. But if you give more detail, then we can give some other better approach.

    And also in your previous code, you have written COC on postinsert but you called insert. Can you make the next call to postinsert as I suggested in my first response? 
  • Martin Dráb Profile Picture
    Martin Dráb 228,212 Most Valuable Professional on at
    How to do action after inserted record in sysdatabaselog table
    I think the records are inserted directly in the database layer, not in the application layer.
  • it.dev Profile Picture
    it.dev 118 on at
    How to do action after inserted record in sysdatabaselog table
    Hi Ayyad,
     
    still can't trigger the action
    [ExtensionOf(tableStr(SysDataBaseLog))]
    final class DatabaseLog_Extension
    {
        public void insert()
        {
            LogStaging logStg;
    
            next insert();
    
            logStg.clear();
            logStg.FileType = "test";
            logStg.insert();
        }
    
    }
    Thanks & Regards,
    Masha
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 5,205 Super User 2024 Season 2 on at
    How to do action after inserted record in sysdatabaselog table
    Hi @ it dev
     
    In the COC your code should be like this: you should call the insert not  postinsert
     
    [ExtensionOf(tableStr(SysDataBaseLog))]
    final class ASP_DatabaseLog_Extension
    {
        public void insert()
        {
            ASP_IntegrateLoggingStaging logStg;
            next insert(); 
            //Action
        }
    }
     
    Regards,
    Waed Ayyad
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
     
     
  • it.dev Profile Picture
    it.dev 118 on at
    How to do action after inserted record in sysdatabaselog table
    Hi Bharani,
     
    I try using this code and still not work
    [ExtensionOf(tableStr(SysDataBaseLog))]
    final class ASP_DatabaseLog_Extension
    {
        public void postInsert()
        {
            ASP_IntegrateLoggingStaging logStg;
    
            next insert();
    
            //Action
        }
    
    }
    Thanks & Regards,
    Masha
  • Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,538 Moderator on at
    How to do action after inserted record in sysdatabaselog table
    If it is not triggering, you can write COC on post next or we have postInsert method in the insert of this table where you can use it for writing code. Let me know if this works.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,349 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,212 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans