How to – Immediately (sync)bulk delete AsyncOperation or Workflow System Job records in Dataverse (Dynamics 365 / CRM)


Recently we noticed File usage of some of our environments reaching around 50 GB, and most of it was because of the AsyncOperation table.

async

So to quickly delete the AscyncOperation records the option we can choose is –

Create a new Bulk Record Deletion job from Settings >> Data Management

Select System Jobs table and filter as System Job Type equals Workflow

Select Bulk deletion job start time as Immediately

The Immediately option will only be available –

  • For entity – System Jobs
  • Filter Criteria is System Job type equals Workflow (we can add additional criteria)
  • User has organization-level
    delete rights on AsyncOpertion entity.

This will only delete the AsyncOperation records that are in the completed state of system job type workflow.

It will delete 1 million records whenever it is run. If there are more than 1 million records, it will have to be run again.

The key part is that it will delete the records through direct SQL Execution, so the records will be deleted immediately, rather than each record going through the delete pipeline, thus improving the performance immensely.

Back to our bulk deletion job, we can click on Submit to initiate the deletion.

We encountered a few errors when submitting, the solution was to keep trying, and eventually it will get submitted successfully.

error

After successful submission, we can see all our completed workflow system job records deleted immediately.

Also as it is Sync Job, we will not see it listed in Bulk Record Deletion views.

Get more details here –

https://cloudblogs.microsoft.com/dynamics365/it/2018/06/21/cleaning-up-records-from-the-asyncoperationbase-workflowlogbase-table/

https://docs.microsoft.com/en-us/power-platform/admin/free-storage-space#reduce-file-storage

Hope it helps..

Advertisements

Power Apps grid control in Model-driven apps (Dynamics 365 / CRM)


Power Apps grid control is a new read-only control, now auto-enabled as part of 2022 Release Wave 1 for Model-driven apps.

We can also enable it by navigating to Customization, selecting the entity, then the Controls tab, and clicking on Add Control option.

Select the Power Apps Grid control.


Here we have enabled it for the Web.

The different properties that can be set for the control are –

  • Jump bar – this will be disabled by default.
  • Reflow behavior
  • Allow filtering

With Jump bar disabled –


Enable the jump bar.

After enabling the jump bar, we get the option to filter by alphabets.

It will also support Infinite Scrolling

We can use Edit Columns to add, remove and order the columns for the view

Edit Filters allows us to edit the filters.

Any changes made to the column or filter can be saved as a personal view.

Also, Grid remembers the context, here we have filtered the record by search text = “Blue”

Let us open the first record.

On navigating back, the context is retained.

We can also show and hide the Edit Columns and Edit filters option on views from Power Platform Admin Center >> [Environment] >> Settings >> Features >> Grid and Views section


Hope it helps ..

Advertisements

Manage and share views in Modern Advanced Find – Dataverse (Dynamics 365 / CRM)


Let us have a quick look at this new feature introduced as part of 2022 Release Wave 1.

Make sure we have updated the environment to 2022 Release Wave 1.

Then navigate to [Environment] >> Settings >> Features

Switch On – Modern Advanced Find and Allow users to hide system view 


Reset Default View
is the only option available before we switch on the Modern Advanced find feature.


After enabling the Modern Advanced Find feature

We get the option to Search Views as well as Manage and share views


Search Views – It allows us to filter / search within the views.


Manage and share views – It opens the dialog listing the views.


We can sort by

  • Personal before system, A to Z
  • System before personal, A to Z
  • A to Z


To hide a view we can select hover and select the option to hide.

With Allow users to hide system views  option switched on, the user has the option to hide system view also, else he could only hide the personal views.


For System Views, we have the option to either Hide or Set as a default view.

For Personal Views, we have more options like 

Hide, Set as default view, Share etc. as shown below.

Learn everything about the new Modern Advanced Find View  – https://jukkaniiranen.com/2022/02/modern-advanced-find-test-drive/

https://powerapps.microsoft.com/en-us/blog/modern-advanced-find-with-enhanced-view-management-in-model-driven-apps/

Hope it helps..

Advertisements

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; " +
                  "Username=User1@xxxx.onmicrosoft.com; " +
                  "Password=*******; " +
                  "RedirectUri=app://58145B91-0C36-4500-8554-080854F2AC97;" +
                  "Url = https://xxx.crm.dynamics.com//;";


            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..

Advertisements

How to – Use Do until and Delay in Power Automate


Let us take a simple example to understand the usage of the Do unit with Delay control in Power Automate.

“When a Case Record’s Priority is updated to High until the case is resolved we want to perform certain action e.g. send a notification email or call an action etc. every 2 minutes or so.”

This is how the final flow looks like –

First is the trigger, when the case record is modified, i.e. priority code field with value as 1.

Next, initialize a Boolean type variable as false, this will be used within the Do until loop condition.

  • Next, add the Do until control with the condition – ConditionMet i.e. the variable is equal to true.
  • Followed by Delay action, here we have specified a 2-minute delay.
  • Next, we are retrieving the same record to check the condition, this is required to get the updated value within the loop.
  • Condition is – is the case resolved? i.e. Status is equal to 1.
  • If Yes then we are setting the variable as true to come out of the do until loop.
  • If No then we perform any action, like send an email notification, reminder or call any action, etc.

The Current Iteration Index of Do unit holds the value of the current index starting from 0. Here we are updating the case title with the index just for testing.

To see it in action, let us Test the flow.

Updating the priority of the case to high triggers the flow.

After a delay of 6 minutes, we can see the Case Title updated with the current index i.e. 2 as it has iterated 3 times starting from 0.

Let us now resolve the case.

We can see our flow successfully completed after the 4th iteration after the case is resolved.

Also refer –

https://techwizard.cloud/2018/05/20/microsoft-flow-mystery-of-do-until-loop/

https://www.futurelearn.com/info/courses/cloudswyft-msft-dynamics-365-power-platform-auto/0/steps/208142

Hope it helps.

Advertisements

How to – manage who can create environments in Power Platform


Through the Power Platform admin center, the administrator can control who can create an environment in the Power Platform.

Click on Gear Icon >> Power Platform settings

There we can specify who can create production and sandbox environments & trial environments.

Let us set it as Only specific admins and save the settings.

With this particular setting now only the following admins will be able to create environments.

Global admin, Dynamics 365 Admin, and Power Platform admins.

The non-admin user will get the below error

Your tenant’s administrators have disabled trial environment creation for non-admin users. You need permission to create a trial environment in your tenant

In case of Everyone, the below license determines who can create environments.

https://docs.microsoft.com/en-us/power-platform/admin/create-environment#who-can-create-environments

Hope it helps..

Advertisements