How to – Use RetrieveAttributeChangeHistoryRequest to get audit data for an attribute (Dataverse/ Dynamics 365/ CRM)

We can use RetrieveAttributeChangeHistoryRequest to get the change history of a particular field / attribute of a record.

We need to set the Target and the AttributeLogicalName property of the request.

AuditDetails records of the RetrieveAttributeChangeHistoryResponse contains the detail of the audit records.

The Audit History records in CRM- 

AttributeAuditDetail contains the details of the changes made on the field’s value. It contains property like – objectid, userid, operation etc. as well as new value and the old value as shown below.

Sample Code (C#) 

 string ConnectionString = "AuthType = OAuth; " +
                  "AppId=51f81489-12ee-4a9e-aaae-a2591f45987d; " +
                  "; " +
                  "Password=*******; " +
                  "RedirectUri=app://58145B91-0C36-4500-8554-080854F2AC97;" +
                  "Url =;";

            CrmServiceClient svc = new CrmServiceClient(ConnectionString);

            if (svc.IsReady)

                var attributeChangeHistoryReq = new RetrieveAttributeChangeHistoryRequest();

                attributeChangeHistoryReq.Target =
                    new EntityReference("incident", new Guid("0a9f62a8-90df-e311-9565-a45d36fc5fe8"));
                attributeChangeHistoryReq.AttributeLogicalName = "prioritycode";

                var attrChangeResponse = (RetrieveAttributeChangeHistoryResponse)svc.Execute(attributeChangeHistoryReq);
                var auditDetailCollection = attrChangeResponse.AuditDetailCollection;

                foreach (var auditDetails in auditDetailCollection.AuditDetails)
                    // Type =  AttributeAuditDetail, AuditDetail, 
                    var type = auditDetails.GetType();

                    if (type == typeof(AttributeAuditDetail))
                        var attributeDetail = (AttributeAuditDetail)auditDetails;

                        var userName = attributeDetail.AuditRecord.GetAttributeValue<EntityReference>("userid").Name;
                        var operation = attributeDetail.AuditRecord.FormattedValues["operation"];
                        var action = attributeDetail.AuditRecord.FormattedValues["action"];
                        var createdOn = attributeDetail.AuditRecord.GetAttributeValue<DateTime>("createdon");
                        var newValue = attributeDetail.NewValue.FormattedValues["prioritycode"];
                        var oldValue = attributeDetail.OldValue?.FormattedValues["prioritycode"];


Check other posts on Audit

Hope it helps..


How to – Use AlwaysMoveRecordToOwnerBusinessUnit setting in Dynamics 365 / PowerApps/ Dataverse

The setting – AlwaysMoveRecordToOwnerBusinessUnit allows us to move a user to another business unit without moving all his owned records to that unit.

This makes sure that other users in the new business unit cannot access the user’s records from his previous business unit (unless they have organization-level access / or have a role in that unit / or records are shared)

Also Check –

EnableOwnershipAcrossBusinessUnits setting

Modernize Business Units

By default this setting is true.

Get the Organization Settings Editor –

Let us see the default behavior first, below are the 2 contact records created by User 2 who belongs to BU 1.

Now let us change the Business Unit of User 2 to BU 2.

After changing the BU of the user 2 we have assigned the same security role to the user which he has had in BU 1 that gave him BU level access on the Contact records.

We can see both Owner and Owning Business Unit getting updated as expected.

Now we’d see what will happen if we update the setting AlwaysMoveRecordToOwnerBusinessUnit to False.

But before doing that let us change the business unit of User 2 back to BU 1.

As expected Owning Business Unit is updated back to BU 1

Now let us update the setting to false

This time changing the business unit of User 2 to BU 2 should not update the Owning Business Unit of the contact records owned by User 2 to BU2.

As expected this time the Owning Business Unit remained BU 1.

Based on the true or false value set for AlwaysMoveRecordToOwnerBusinessUnit , we can see the checkbox “Move records to new business unit” either checked or unchecked – but always DISABLED.

If AlwaysMoveRecordToOwnerBusinessUnit is true than – the disabled checkbox is checked – 


Get more details below –

Hope it helps..


How to – change user’s business unit without removing the security roles in Dynamics 365 / PowerApps (EnableOwnershipAcrossBusinessUnits setting)

When we change the user’s business unit, all the current security roles of the users are removed and we need to assign the roles again to the user. This has always been the default behavior. 

Also check – Modernize Business Units –

For E.g. below user User 2 belongs to Business Unit – BU 1 and has the following security roles assigned.

Now changing the user’s business unit to BU 2

will remove all his security roles assigned.

We can now override this behavior by updating the new option /setting added

EnableOwnershipAcrossBusinessUnits (this property determines if roles are removed when the principal changes business units) through the
Organization Settings Editor tool

After we have installed the managed solution, we can update the setting and set it as true

Let us assign the security roles to User 2 in BU 2.

Let us now change the BU of user 2 back to BU 1.

As expected after updating that setting – DoNotRemoveRolesOnChangeBusinessUnit– as true – we can see the security roles still intact, even on the change of Business Unit for the user.

What happens if user 2 is assigned a security role – BU2 Security Role, which is created in BU 2 Business unit and is not available in BU 1.

Let us change the business unit to BU 1.

As expected BU2 security role is not available in BU 1, so that role is not assigned, only the common security role coming from parent BU remains intact.

Hope it helps..


Modernize Business Units / Matrix data access structure -Record ownership across business units (Preview) in Dynamics 365 / Dataverse

To enable this preview feature, log in to the Power Platform admin center, switch on the

Environment >> Settings >> Features >> Record ownership across business units (Preview)

It took around 5 minutes to enable.

Now let us say we have a BU structure like below.

And custom security roles with BU level access to Contact – BU Contact Role.

Both user 2 and user 3 have only the BU Contact Role of BU 1 and BU 2 business unit respectively assigned.

Below is the Contact record created by User 2.

As expected User 3 does not have access to the above record.

Now let us provide the same BU Contact role to User 3 but this time from BU 1.

Select the User 3 in Settings >> Users >> Manage Security Roles

The user has already has BU Contact Role in BU 2. Let us change the Business Unit and assign the same role for BU 1.

Click on Save.

On refreshing the All Contacts view for user 3 now we can see both the records, showing the corresponding owner and the owning business unit the records belong to.

This makes it easy to provide required access to the users across the business unit, without the need of sharing the record or using team access or teams ownership concept here.

With this preview, we can also update the Owning Business Unit field.

Below the User 2 is creating a new contact record and setting Business Unit as BU 2.

Here it fails because User 2 only has BU level access for Contact Create Rights, and he is trying to create at BU 2.

Let us update one of the existing contact records, by setting Owning Business Unit as BU 2, this time through System Administrator user which belongs to the root Business Unit.

As expected the record is available to User 3, as we have set BU 2 as the owing business unit.

Get all the details here—preview

Hope it helps..


Modern link sharing UI, co-presence, online status (preview) in the model-driven app (Dynamics 365)

To enable the Collaboration preview feature, log in to the Power Platform Administration Center, select the Environment >> Settings >> Features >> Collaboration

Currently, the following entities are supported – Case, Contact, Account, and Opportunity.

Enabling this feature adds a new section in the command bar for the records, that allows us to see the other users working on the same record.

Here we can see 2 other users working on the same contact record.

We can select the user’s picture to see their status, send an email, start teams chat, and open the contact card.

Send Email opens the default mail app with To populated.

Teams chat opens the team for a chat.

Open contact card opens the contact’s card.

Share allows emailing the link of the current record and sharing the record.

Email link

Clicking on Manage access opens the share records dialog.

Get all the details here –

Also check – Collaborate using comments –

Hope it helps.. 


Quickly visualize the VIEW data using Power BI quick report (preview) in Dynamics 365 / Power Apps

With a recent update to the platform, now we can use Power BI quick report (preview) on the view page in a model-driven app, to visualize the data.

To enable the feature, open the model-driven app in the modern app designer.

Here we are opening the Customer Service Hub app in the modern app designer.

Click on Settings.

Navigate to Features and enable the Power BI quick report visualization on a table option.

Publish and Play the app.

We can see the Visualize this view option added in the command bar for all the views within the app.

It asks for getting a power bi license if we do not have one.

Click on Get a free license and set up the Power BI Account.

Now Visualize this view option will open the Power BI report.

The visuals will run under the context of the view selected – All Contacts in this case.

The visuals will use some of the fields and add additional fields to the table in the report.

Here we are running it against the My Cases view.

The Power BI quick report –

The report gets updated based on the fields selected in the data pane. Power BI adds or removes charts based on the selected fields as shown below.

We can also further Personalize the visual

Visualize this view doesn’t run on selected records for a view.

The option is also available for the Activities view.

The option also works on a Custom table/entity.

Get all the details here –

Hope it helps..

%d bloggers like this: