Activity Logging – Dynamics 365 Apps


Microsoft 365 Security and Compliance Center – provides easy access to the data and the tools to manage the compliance need of an organization, and also can be used to review the different data processing activities within Dynamics 365 Customer Engagement apps.

It required Microsoft 365 E3 or E5 subscription and is only available for Production environments.

The events logged are –

  • CRUD, Export to Excel, SDK Calls.
  • CRUM and backend activities performed by the support engineer.
  • Report – viewed, exported, multimedia assets shown in the Report

For this first Auditing needs to be enabled in the environment.

Navigate to Settings > Administration > System Settings > Auditing Tab

Navigate to Compliance Center

https://protection.office.com/

Search > Audit Search Log and
Turn on auditing.



To try the new experience within the Compliance center

https://compliance.microsoft.com/auditlogsearch?viewid=Search


After around 1 hour or so, the settings got enabled.


As specified Office 365 logs are being prepared, if we try searching we’d get blank results


Below are the list of Dynamics 365 and Power Apps activities that can be tracked


Around after 3 hours or so – we saw the results appearing.

Export has 2 options –

Save loaded results –

Download all results –

At the same time there we 51 records in Audit Summary View.

Apart from searching for an audit log, we can also define an audit retention policy as shown below

Get the sample files here –

https://drive.google.com/file/d/1akifraP1NCV-KgmA-8ROhm8r4h0tAcLi/view?usp=sharing

https://drive.google.com/file/d/1s_EbJ4hraDl6YEVUCMkOe6bQbXCJu_5-/view?usp=sharing

Get all the details here

https://docs.microsoft.com/en-gb/microsoft-365/compliance/search-the-audit-log-in-security-and-compliance?view=o365-worldwide

Hope it helps..

Using RetrieveRecordChangeHistoryRequest to get Audit Detail in Dynamics 365 CE


Just sharing a sample code to retrieve the Audit Detail using RetrieveRecordChangeHistoryRequest.


RetrieveRecordChangeHistoryRequest changeRequest = new RetrieveRecordChangeHistoryRequest();
changeRequest.Target = new EntityReference("entitySchemaName", "entityId"));
RetrieveRecordChangeHistoryResponse changeResponse =
(RetrieveRecordChangeHistoryResponse)_service.Execute(changeRequest);

AuditDetailCollection auditDetailCollection = changeResponse.AuditDetailCollection;

foreach (AttributeAuditDetail attrAuditDetail in auditDetailCollection.AuditDetails)
{
var auditRecord = attrAuditDetail.AuditRecord;

Console.WriteLine("Entity: " + ((EntityReference)auditRecord.Attributes["objectid"]).LogicalName);
Console.WriteLine("Operation: " + auditRecord.FormattedValues["operation"]);
Console.WriteLine("Action: " + auditRecord.FormattedValues["action"]);

var newValueEntity = attrAuditDetail.NewValue;

foreach(var attrNewValue in newValueEntity.Attributes)
{
Console.WriteLine("New Key: " + attrNewValue.Key + "New Value: " + attrNewValue.Value);
}

var oldValueEntity = attrAuditDetail.OldValue;

foreach (var attrOldValue in oldValueEntity.Attributes)
{
Console.WriteLine("Old Key: " + attrOldValue.Key + "Old Value: " + attrOldValue.Value);
}
}

The record whose Audit History we are retrieving :

Output :

AuditDetail.AuditRecord :

AuditDetail.OldValue n NewValue:

Hope it helps..