Extending Custom Table Event Logging

Lea Lebonski asked on April 13, 2021 06:36

Hi there,

I am looking to provide some additional information in the Event Log for changes to Custom tables. E.g. When a field is created, I want to log which field has been created. For the Custom table items, I would like to log which item exactly has been changed from what to what. eg. In Custom table "Data", Row ID "3", value of column "Year" has changed from 2020 to 2021. What would be the best approach?

At the minute I am only getting basic logs of UserID and field update or item update. When I looked into the code for CustomTable_Edit_Fields.aspx.cs, it seems that details of new guid creation should be logged.

       var logData = new EventLogData(EventTypeEnum.Information, "Custom table", "GENERATEGUID")
        {
            EventDescription = String.Format(ResHelper.GetAPIString("customtable.GUIDGenerated", "Field 'ItemGUID' for custom table '{0}' was created and GUID values were generated."), dci.ClassName),
            UserID = currentUser.UserID,
            UserName = currentUser.UserName,
        };

However this does not appear in the Event Logs. Do I need to turn on more detailed logging somewhere? I had a look in the settings application but there is nothing obvious.

Would you have any advice on this matter?

Thank you.

Lea

Correct Answer

Juraj Ondrus answered on April 13, 2021 08:30

I would use the custom table item event handlers and then use the Event log API inside the handlers to log the information you need. In the before/after update events you should be able to get the original as well as updated data.

0 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.