Sample Code – Update format of Autonumber attribute in Dataverse (Dynamics 365 / CRM)


At times we may have a requirement to update the format of the Auto Number dynamically / programmatically so that the new set of records take up the new format.

Let us understand through a simple example.

Right now for the below field, we have the auto-number format set as

{SEQNUM:4}


Below is the sample code to update the auto-number format programmatically.

It makes use of our RetrieveAttribute and UpdateAttribute requests.

https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/create-auto-number-attributes?view=op-9-1#autonumberformat-options

We have retrieved the attribute then have specified a new auto number format, followed by update request.

After executing the above code successfully, and creating a new contact record we can see the new number generated as per the specified format.

Sample Code

        string ConnectionString = "AuthType = OAuth; " +
              "AppId=51f81489-12ee-4a9e-aaae-a2591f45987d; " +
              "Username=test@test.onmicrosoft.com; " +
              "Password=test; " +
              "RedirectUri=app://58145B91-0C36-4500-8554-080854F2AC97;" +
              "Url = https://test.crm.dynamics.com/;";


        CrmServiceClient svc = new CrmServiceClient(ConnectionString);

        if (svc.IsReady)
        {
            var retAttributeRequest = ((RetrieveAttributeResponse)
                             svc.Execute(new RetrieveAttributeRequest
                             {
                                 EntityLogicalName = "contact",
                                 LogicalName = "cr59f_myautonumber",
                                 RetrieveAsIfPublished = true
                             })).AttributeMetadata;

            retAttributeRequest.AutoNumberFormat = "MyFormat-{SEQNUM:6}-{DATETIMEUTC:yyyyMMddhh}-{RANDSTRING:6}";

            var updateAttrRequest = new UpdateAttributeRequest
            {
                EntityName = "contact",
                Attribute = retAttributeRequest
            };

            var updateAttrResponse = (UpdateAttributeResponse)
                svc.Execute(updateAttrRequest);

Check other posts on Auto Number attribute –

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 SetAutoNumberSeed Action to reset/update the seed for the Autonumber attribute – DataVerse (Dynamics 365 / CRM)


Suppose we have the following Autonumber field created with

Seed value1000 and Format{SEQNUM:4}

Now based on a certain requirement, we want to dynamically / programmatically update / reset the seed value.

For this, we can make use SetAutoNumberSeed Action

Below we can see the auto number set as 1007 on creating a new contact record.

Now to set it back to 1000 we can run the following code –

On executing the action, we can see the next contact record having autonumber field set as 1000.

Another example –

On updating the value to 888, and creating a new contact record

Sample code –

                OrganizationRequest customActionRequest =
                    new OrganizationRequest("SetAutoNumberSeed");

                // name of the entity
                customActionRequest["EntityName"] = "contact";

                // attribute's schema name
                customActionRequest["AttributeName"] = "cr59f_myautonumber";

                // the value we want to set
                customActionRequest["Value"] = Convert.ToInt64(888);

                OrganizationResponse customActionResponse = 
                    svc.Execute(customActionRequest);

Check other posts –

https://powerobjects.com/tips-and-tricks/auto-number-d365-version-9/

Hope it helps..

Advertisements

How to – Delete Audit data by entity / table, date, user access, and specify retention duration – updates in Dataverse (Dynamics 365 / CRM)


Recently we saw a new update in our sandbox environments with regards to Audits.

Login to Power Platform Admin Center, select an environment.

We can see a new section Auditing added.

Click on Delete logs allows us to –

  • Delete logs by Table

We can select the tables there.

  • Delete only access logs data.
  • Delete logs up to the selected date.

And now we can also manage or specify the retention duration for the audit log.

These are very useful updates to the Audit feature in the platform which more or less have been similar since CRM 3.0 days.

Check other posts on Audit – 

https://nishantrana.me/2021/08/31/audit-entity-table-few-key-points-dynamics-365-power-apps/

https://nishantrana.me/2021/05/17/how-to-export-the-audit-history-values-from-dynamics-365/

https://nishantrana.me/2018/10/08/using-kingswaysofts-cds-crm-source-component-to-get-audit-information-in-dynamics-365-ce-ssis/

How to – Use RetrieveAttributeChangeHistoryRequest to get audit data for an attribute (Dataverse/ Dynamics 365/ CRM) – Nishant Rana’s Weblog

Hope it helps..

Advertisements

How to – Set up Dynamics 365 Customer Insights Trial


https://nishantrana.me/2022/02/09/how-to-import-data-from-local-data-files-to-dynamics-365-customer-insights/To set up the trial of Customer Insights, open the Dynamics 365 Free Trial Page and scroll down to Dynamics 365 Customer Data Platform section

https://dynamics.microsoft.com/en-gb/dynamics-365-free-trial/

Click on Try for free

Sign in with your work account or the Dynamics 365 trial account created and click on Get Started

As a first step, it asks for specifying the region for the communication preferences.

For the trial, let us choose the Audience Insights option.

It opens the Demo environment having the sample data. We can explore and understand the features with the sample data or we can start a trial.

Let us select the option Start trial in the tool bar to connect it to an existing CRM / Dataverse Environment.


Enter the basic information requested. Make sure you have selected the correct region else you might get unable to create an environment error later.

The data storage option comes as disabled.

Specify the Dataverse / CRM environment’s URL. (here I am logged in with System Administrator user who is also the Global Admin)

Finally, review the information and click on Create.

This will configure a 30 day trial against the CRM / Dataverse environment.

Now we are ready to explore it further.

How to – Import Data from Dataverse / CRM to Dynamics 365 Customer Insights

How to – Import Data from local data files to Dynamics 365 Customer Insights

How to – Unify (Map, Match and Merge) Entities in Dynamics 365 Customer Insights

Hope it helps..

Advertisements