I posted a similar question last week about RetrieveAttributeChangeHistoryRequest and we discussed issues around permissions and the entity being auditable, but no one offered any suggestions as to why CRM might be allowing AuditDetails and not AttributeAuditDetails when the user is an admin and the entity is being audited. So, I wanted to ask a similar question and see if anyone had some ideas or suggestions. I'm getting close to wondering if there might be a bug in the current version of CRM but I am not ready to say that just yet, as it seems that something here is controlling this.
My problem is simply that RetrieveAttributeChangeHistoryRequest will return AuditDetails but will not return AttributeAuditDetails no matter what I do. It seems to me there must be more going on here that simply permissions. For example, would a custom entity that is not in a managed solution get blocked? Are their configuration settings on the entity that need to be set?
Does anyone know if the CRM SDK requires that the calling application be a service vs a winForm application? I am testing the code in a winForm application and pass my own credentials in through the connection string. I have also tested it using one of the CRM system admin accounts that we run services with and I get the same results.
If I dump the Entity Defintion I see that there are attributes such as IsVisibleInMobileClient and many others, most of which are set to false. Are there attributes on custom entities that might not allow a winForm app to view the RetrieveAttributeChangeHistoryRequest AttributeAuditDetails, but would allow AuditDetails?
Running out of ideas here to get this to work. Just seems odd that I can get AuditDetails but no AttributeAuditDetails. All of offical Microsoft pages that provide details, they all just say that you have to have the right audit level permissions, which I do as an admin, and that the entity has to be auditable, which is it. There are literally 500M audit records in the Audit table for this entity. So auditing is enabled.
So what else might block my winForm from getting access to the AttributeAuditDetails? Any thoughts?
I see the issue now. It's because you cannot select audit records without first selecting a given entity record and field. I thought you could select all of a given entity's audit records and loop through the results to process them one at a time, but you cannot. You have to first select a list of entity records and a given field on the entity to loop through the audit records of that specific entity and field. When you do this, you are able to access to the AttributeAuditDetail records.
I don't see a good way to just process through audit records to determine which ones are redundant and that can be removed, but I can simply load the audit records through say a RetrieveMultiple query and process them that way. Outside the SDK Audit APIs. Just treating them the same as any other entity using the SDK query.
That's a good point. Certainly the audits could have been turned on/off at different times, so maybe at that time only details were saved. I suspect that is not the case because I am using some new data. But I need to dig into this a bit to confirm. Thanks for the suggestion.
I have noticed that it only retrieves 9 audit-detail records at any time. Does that seem odd to you? It always seems to find only 9 records. I did adding paging info as well, so I set it to pagenumber 1 and count of 25. But it still finds just 9 records. When I create a SQL query to find the same record for the given entity and attribute, it finds 2200 records. This seems odd, like something is controlling this that I am not aware of. It only finds 9 really old records and I cannot get it to move forward to the most recent records using paging info because when I use that, it only finds the 9 and nothing else. Seems really stange to me.
I'm getting close to just abandoning the CRM SDK and the Audit API and just using SQL directly to purge old Audits that we no longer need. But it seems like using the SDK would be the beter approach to identify them. I'm just not sure it is able to handle what I am trying to do. Of course, the SDK doesn't support deleting audits by record, so I guess I will have to jum over to SQL at some point anyway.
One possible scenario: the audit is enabled after record and attribute changed/modified, so there is only AuditDetails for some old records. Maybe you can try out some newer records?
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156