I have written a console app to try and retrieve audit data from a filtered list of Cases. The audit data I want is specific, it's from the field Status Reason - I want the Change Date value of when it was last updated to the value Pending Closure
The result from my console app is an error:
This is the code I've got so far, but i just can't quite get it to show any audit data at all :(
string EntitySchemaName = "incident", AttributeSchemaName = "statuscode"; foreach (var caseRecords in results.Entities) { string CaseName = caseRecords.Attributes["title"].ToString(); string CaseNumber = caseRecords.Attributes["ticketnumber"].ToString(); string CaseGUID = caseRecords.Attributes["incidentid"].ToString(); _CaseId = new Guid(CaseGUID); try { RetrieveAttributeChangeHistoryRequest attributeChangeHistoryRequest = new RetrieveAttributeChangeHistoryRequest { Target = new EntityReference(EntitySchemaName, _CaseId), AttributeLogicalName = AttributeSchemaName }; RetrieveAttributeChangeHistoryResponse attributeChangeHistoryResponse = (RetrieveAttributeChangeHistoryResponse)service.Execute(attributeChangeHistoryRequest); foreach (var EachEditRecord in attributeChangeHistoryResponse.AuditDetailCollection.AuditDetails) { AttributeAuditDetail attributeDetail = (AttributeAuditDetail)EachEditRecord; System.Console.WriteLine(attributeDetail); System.Console.WriteLine(EachEditRecord); } } catch (Exception e) { Console.WriteLine("Failed to fetch data. \nReason {0}", e.Message); } Console.ReadLine();
*This post is locked for comments