Base solution for your next web application
Open Closed

Audit logging on Dynamic Entity Properties #9763


User avatar
0
devinedon created

Hi there,

What is the best approach to enable tracking on a dynamic properties itself? We are already using dynamic properties and finding it very effective however we would love some history changes along with who modified it (UserID).

Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

2 Answer(s)
  • User Avatar
    0
    zony created
    Support Team

    Hi devinedon, As far as I know, the relevant functions are not currently implemented. You can try to retrieve Entity History, or rewrite IDynamicEntityPropertyValueManager and add auditing when setting the value logic.

    public class CustomValueManager : DynamicEntityPropertyValueManager
    {
        public CustomValueManager(IDynamicPropertyPermissionChecker dynamicPropertyPermissionChecker,
            IDynamicPropertyManager dynamicPropertyManager,
            IDynamicEntityPropertyManager dynamicEntityPropertyManager) : base(dynamicPropertyPermissionChecker,
            dynamicPropertyManager,
            dynamicEntityPropertyManager)
        {
        }
    
        public override void Update(DynamicEntityPropertyValue dynamicEntityPropertyValue)
        {
            // Your audit code.
            base.Update(dynamicEntityPropertyValue);
        }
    }
    

    Module Code:

    public class YourAnyModule : AbpModule
    {
        public override void PreInitialize()
        {
            Configuration.ReplaceService<IDynamicEntityPropertyValueManager, CustomValueManager>(DependencyLifeStyle.Transient);
        }
    }
    
    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    devinedon created

    Great thanks! This makes sense. Will get going with this ASAP

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)