AuditDereferenceOfRelatedEntity but not during ReferenceOfRelatedEntity

Posts   
 
    
TomDog
User
Posts: 623
Joined: 25-Oct-2005
# Posted on: 13-Aug-2012 13:56:44   

Is it possible to implement AuditDereferenceOfRelatedEntity and AuditReferenceOfRelatedEntity but not create a dereference log entry when a RelatedEntity entity is changed to another one?

e.g. An Order is fetched with ShipperA. When Order.Shipper is set to ShipperB I want a log entry saying something like 'Shipper was changed from ShipperA to ShipperB' But if I implement AuditDereferenceOfRelatedEntity I will also get a an unwanted entry like 'Shipper was changed from ShipperA to "' which is what I want if I actually null the Order.Shipper reference.

Is there an easy way to do this?

Jeremy Thomas
Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 13-Aug-2012 21:27:02   

I think you can do that in your Auditor code. You can keep track of whatt was dereferenced in the AuditDereferenceOfRelatedEntity (), and check this track records in the AuditReferenceOfRelatedEntity(), and so you can grab the dreference Audit Log entity, and either change it or delete it from the Audit Entities Log.

TomDog
User
Posts: 623
Joined: 25-Oct-2005
# Posted on: 15-Sep-2012 12:47:19   

Yeah that's what I had to: Keep a record of what was last deferenced and check that during a AuditDereferenceOfRelatedEntity and if they match just delete the last entry in the log(which is a string, one line per entry), this seems a bit brittle but probably the best I can do. I was hoping there was some way to tell I was in the middle of a reference during a AuditDereferenceOfRelatedEntity.

Jeremy Thomas