Skip to main content

Posts

Showing posts from September, 2020

Deleting Audit history change records through c#

Mainly I had this requirement where I had to delete audit log to shrink the database size so that it come back within log capacity threshold.  Below is the code for the DeleteRecordChangeHistoryRequest() method usage.  Here I am looping through the records to delete the changed history for a particular entity in my case it is "Customer Asset". static void Main(string[] args) { try {  IOrganizationService _service;  ClientCredentials credentials = new ClientCredentials();  credentials.UserName.UserName = "username";  credentials.UserName.Password = "pwd"; Uri serviceUri = new Uri(@"soapurl"); OrganizationServiceProxy proxy = new OrganizationServiceProxy(serviceUri, null, credentials, null);  proxy.EnableProxyTypes();   _service = (IOrganizationService)proxy; //fetchXML for getting entity  string fetchXML = @"<fetch mapping='logical'>                                           <entity name='msdyn_customerasset'>