Ticket T518215
Visible to All Users

Audit Trail - How to show the current object's change history in a separate dialog window instead of a nested List View

created 8 years ago

Hi,

I am planning to include Audit Trial in my project but the concern i have is the i dont want to create the collection property for Audit Log in every BO i have. Instead, i was thinking to have a ViewController (of DetailView) type and add a popupaction button to it to invoke the log for any BO.

Could you please guide me on that.

So far I have created the following but not sure how to pop this up.

Visual Basic
Private Sub ViewAudit_Execute(sender As Object, e As SimpleActionExecuteEventArgs) Handles ViewAudit.Execute Dim os As IObjectSpace = Application.CreateObjectSpace() Dim master As Object = os.GetObject(View.CurrentObject) Dim sess = DirectCast(Me.ObjectSpace, XPObjectSpace).Session Dim _auditTrail As XPCollection(Of AuditDataItemPersistent) _auditTrail = AuditedObjectWeakReference.GetAuditTrail(sess, master) 'Dim dv As DetailView = Application.CreateDetailView(os, _auditTrail) 'dv.ViewEditMode = ViewEditMode.View 'e.ShowViewParameters.CreatedView = dv End Sub

Answers approved by DevExpress Support

created 8 years ago (modified 8 years ago)

Hello,

There are several good ways to approach this, and in both of them, you will need to create a ListView for the  AuditDataItemPersistenttype and then apply the required filter to the ListView.CollectionSource.Criteria property as described at Concepts > Filtering > Criteria Property of a List View's Collection Source:
1. Compose a filter based on your XPCollection using the DevExpress.Data.Filtering > InOperator feature (see the Q480741 ticket for an example).
2. Compose a filter manually as shown below:

C#
using System; using DevExpress.Data.Filtering; using DevExpress.ExpressApp.Xpo; using DevExpress.Xpo; namespace MainDemo.Module.Controllers { public partial class PopupNotesController : ViewController { private void ShowNotesAction_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs args) { ListView lv = Application.CreateListView(Application.CreateObjectSpace(typeof(AuditDataItemPersistent)), typeof(AuditDataItemPersistent), true); GroupOperator criteria = new GroupOperator(GroupOperatorType.And); criteria.Operands.Add(new BinaryOperator("AuditedObject.TargetType", ((XPObjectSpace)ObjectSpace).Session.GetObjectType(View.CurrentObject))); criteria.Operands.Add(new BinaryOperator("AuditedObject.TargetKey", XPWeakReference.KeyToString(ObjectSpace.GetKeyValue(View.CurrentObject)))); lv.CollectionSource.Criteria["ByTargetObject"] = criteria; args.View = lv; }
Visual Basic
Imports System Imports DevExpress.Data.Filtering Imports DevExpress.ExpressApp.Xpo Imports DevExpress.Xpo Namespace MainDemo.Module.Controllers Partial Public Class PopupNotesController Inherits ViewController Private Sub ShowNotesAction_CustomizePopupWindowParams(ByVal sender As Object, ByVal args As CustomizePopupWindowParamsEventArgs) Dim view As ListView = Application.CreateListView(Application.CreateObjectSpace(GetType(AuditDataItemPersistent)), GetType(AuditDataItemPersistent), True) Dim criteria As New GroupOperator(GroupOperatorType.And) criteria.Operands.Add(New BinaryOperator("AuditedObject.TargetType", CType(ObjectSpace, XPObjectSpace).Session.GetObjectType(View.CurrentObject))) criteria.Operands.Add(New BinaryOperator("AuditedObject.TargetKey", XPWeakReference.KeyToString(ObjectSpace.GetKeyValue(View.CurrentObject)))) view.CollectionSource.Criteria("ByTargetObject") = criteria args.View = view End Sub

See Also:
Concepts > Extra Modules > Audit Trail Module Overview > Customize the Audit Trail System
Audit - How to show audit entries for a current object and for each object from its collection property in one list
How to display audit info for deleted objects

    Show previous comments (9)
    Dennis Garavsky (DevExpress) 8 years ago

      Thanks for sharing, Randy!

      JK JK
      Jacek Kosinski 7 years ago

        how to add to audit list view export and print preview action buttons ?

        Dennis Garavsky (DevExpress) 7 years ago

          @Sławomir: I've created a separate ticket on your behalf (T604959: How to add to audit list view export and print preview action buttons?). For the future, please submit separate tickets for each problem/question you require our assistance with: https://www.devexpress.com/Support/Center/Question/Create
          Otherwise, it makes it difficult to properly track and process threads where multiple subjects are discussed (as in any other forum or support software). This also results in increased response time by obvious reasons.
          Let me know if you experience any difficulties with this in the future. Thanks for your understanding.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.