web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Can't delete audit log!!!

(0) ShareShare
ReportReport
Posted on by

Hello everyone,

I'm trying to delete audit logs from the application through audit log management: Settings –> System –> Auditing –> Audit Log Management. But I received the following error message:

 

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: System.Web.HttpUnhandledException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #0F935E55Detail:
<OrganizationServiceFault xmlns:i="www.w3.org/.../XMLSchema-instance" xmlns="schemas.microsoft.com/.../Contracts">
<ErrorCode>-2147220970</ErrorCode>
<ErrorDetails xmlns:d2p1="schemas.datacontract.org/.../System.Collections.Generic" />
<Message>System.Web.HttpUnhandledException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #0F935E55</Message>
<Timestamp>2015-05-11T13:58:00.7922655Z</Timestamp>
<InnerFault>
<ErrorCode>-2147220970</ErrorCode>
<ErrorDetails xmlns:d3p1="schemas.datacontract.org/.../System.Collections.Generic" />
<Message>Failed to delete audit data from one or more of the specified partitions.</Message>
<Timestamp>2015-05-11T13:58:00.7922655Z</Timestamp>
<InnerFault i:nil="true" />
<TraceText i:nil="true" />
</InnerFault>
<TraceText i:nil="true" />
</OrganizationServiceFault>

With the trace log file, we have the following message:

Exception when executing non-query: p_DeleteSingleAuditPartition Exception: System.Data.SqlClient.SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)

I modified the the registry subkeys OLEDBTimeout and ExtendedTimeout, and the parameters httpRuntime and maxRequestLength at Web.config file, following the resolution at this KB support.microsoft.com/.../918609

 

But I still recive the same erros message, while trying to exclude the audit log file. Do you have any suggestion to solve this problem?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Abe Saldana Profile Picture
    390 on at

    The only method supported for deleting audit records, is using the Audit deletion by date (use something like "all records older than X date"

    if you are on CRM Online there is not a UI way to delete the Audit logs, the best way is to create an external application and using the SDK delete the Audit records, using the method 

    orgService.Delete("audit",auditId);

    In the case that you are on a CRM Onpremises then you have direct access to the database, but remember to backup your database before deleting any records.
  • Verified answer
    Hamzeh Zawahreh Profile Picture
    3,674 on at

    hello,

    There is no support method for deleting Audit Log entries by entity type.  The only method support for audit deletion is by date.

    you can delete it directly from Sql Server:

    You will need the ObjectTypeCode of the entity. You can get this from the database by running the following script:

    SELECT [EntityId],[Name],[ObjectTypeCode]

    FROM [].[MetadataSchema].[Entity] ORDER BY Name

    Now that you have the ObjectTypeCode simply replace the xxxx in the script below with the value and run the script.

    DELETE FROM [].[dbo].[AuditBase] WHERE ObjectTypeCode = xxxx

    ******************************************************

    or you can see this link to delete using plugin:

    msdn.microsoft.com/.../microsoft.crm.sdk.messages.deleteauditdatarequest.aspx

  • Community Member Profile Picture
    on at

    Thank you for the answer.

    I executed that scripts at server, successfully deleted records of the table, but I'm still receiving the erros message while trying to delete from the application.

    Any other suggestion?

  • Suggested answer
    Talsim Profile Picture
    on at

    Hi,

    If You are NOT using enterperise edition of the sql server,

    then it does not support audit partitioning, which in that case you cannot delete the audit records.

    Tal

  • Suggested answer
    purwar purwar Profile Picture
    2,836 on at

    After much research, this KB article solved the problem:

    support.microsoft.com/.../918609

  • Community Member Profile Picture
    on at

    Hi.

    This error occurs because the stored procedure p_DeleteSingleAuditPartition creates an index for a temporary table incorrectly. You must modify the following line in SQLServer:

    CREATE NONCLUSTERED INDEX [fndx_ObjectTypeCode] ON [dbo].[NonPartitionAuditTable] ([ObjectTypeCode] ASC, [Action] ASC)

    by

    CREATE NONCLUSTERED INDEX [fndx_ObjectTypeCode] ON [dbo].[NonPartitionAuditTable] ([ObjectTypeCode] ASC)

    then, try again to delete audit logs from the application through audit log management: Settings –> System –> Auditing –> Audit Log Management.

  • Community Member Profile Picture
    on at

    Knowledge base article suggestion worked! Thank you!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans