Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

How to do action after inserted record in sysdatabaselog table

Posted on by 122
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... 291,280 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,605 Super User 2024 Season 1 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 230,214 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 122 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 6,332 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 122 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,605 Super User 2024 Season 1 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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans