Get attribute value audit, history

What for

Sometimes, there is necessity of getting historical values for entity attribute. Of course to do so audit for organization, entity and attribute have to be turned on. Code below allows user, with proper privileges, to read attribute value audit. For sure if you need fancy validation this code is no good for that. It’s just an example how to read the data. If you have other examples I would like to hear about them.

var stageAdapter = new CRMServiceAdapter("http://serverName", "orgName");
var organizationService = stageAdapter.Proxy;

var opportunityId = new Guid("BB065CC6-9298-E311-9410-005056894DD9");
var attributeName = OpportunityCustomFieldsNames.TimeProgress;

var recordAuditRequest = new RetrieveAttributeChangeHistoryRequest()
        AttributeLogicalName = attributeName,
        Target = new EntityReference(Opportunity.EntityLogicalName, opportunityId)

var recordAuditResponse = (RetrieveAttributeChangeHistoryResponse)organizationService.Execute(recordAuditRequest);

foreach (var auditDetail in recordAuditResponse.AuditDetailCollection.AuditDetails)
    if (!(auditDetail is AttributeAuditDetail))

    var attributeDetail = auditDetail as AttributeAuditDetail;

    var oldValue = attributeDetail.OldValue.GetAttributeValue<decimal>(attributeName);
    var newValue = attributeDetail.NewValue.GetAttributeValue<decimal>(attributeName);

Have an own opinion?