Blogs


  • D365 CRM: Configure Application User to use it in the Connection String


    Now is a good practice to use an Application User instead of a User/Password to connect to the SDK API for security purpose. To archive this, you need to follow these steps in your Azure Tenant:
    -Create an App Registration under Azure Active Directory:
     


    -Set the name that will be displayed in D365. Leave the Supported account type as Single Tenant (default value).
    -Once created, copy the Application (client) ID to use later as the Client ID and the Directory (tenant) ID to use later as the Tenant ID:
     
    -Navigate to Certificates & secrets and click New client secret, under Client secrets:
     
    -Enter a description for the client secret and select the expiry date for the client secret. The maximum you can select is 24 months. After the expiry, a new secret will need to be generated, and any applications using the secret will need to be updated. It’s worth setting a reminder for this, to avoid any service interruptions.
    -Once the secret is created, copy the Value. This will be used as the Client Secret later. This is the only chance you’ll have to copy the secret, so be sure to save it somewhere safe. If you lose the value, you can always generate another later.



    -Navigate to API permissions and select Add a permission:

    -From the Request API permissions screen, located Dynamics CRM:
     
    -Under Delegated permissions, select user_impersonation and then Add permissions:
     
    -Open the Power Platform Admin Center as a System Administrator, and select your Dynamics 365 Environment, select Settings, under Users + permissions select Application users:
     
    -Click New app user, click Add an app, select the App you created earlier. Then select the Business Unit and add the System Administrator role:

    To finish, in your code that needs to consume the SDK API, configure the connection string using the Client ID, the Client Secret and the Tenant ID copied in the previous steps like this:
    AuthType=Secrets;url=https://{CRM_ORGANZATION}.api.crm.dynamics.com;secret={CLIENT_SECRET};AppId={CLIENT_ID};tenantid={TENANT_ID};RequireNewInstance=true;SkipDiscovery=true

    Original Source:
    https://blog.magnetismsolutions.com/blog/paulnieuwelaar/2021/09/21/setting-up-an-application-user-in-dynamics-365

    Enjoy it!

    Continue reading...



  • D365 CRM: Update user setting using C# SDK API


    Sometimes you need to update a specific configuration of the users, for example the default time zone of the system. By default, these settings are Personal, so every user needs to be notified to change this by hand. But you can do it using an entity in the API called UserSettings. Let’s take this example: you need to update the default time zone of all users in your CRM system. To do that you need to retrieve all the active users first and for each one you need to update his/her time zone:

    1.    ColumnSet myColumnSet = new ColumnSet();
    2.    myColumnSet.AddColumn("fullname");
    3.    myColumnSet.AddColumn("systemuserid");
    4.    myColumnSet.AddColumn("businessunitid");
    5.    
    6.    QueryExpression query = new QueryExpression();
    7.    query.EntityName = "systemuser";
    8.    query.ColumnSet = myColumnSet;
    9.     
    10.    ConditionExpression condition = new ConditionExpression();
    11.    condition.AttributeName = "isdisabled";
    12.    condition.Values.Add(false);
    13.    condition.Operator = ConditionOperator.Equal;
    14.    query.Criteria.AddCondition(condition);
    15.     
    16.    // Get all the active users
    17.    EntityCollection results = Service.RetrieveMultiple(query);
    18.    if (results != null && results.Entities.Count > 0)
    19.    {
    20.       foreach (Entity item in results.Entities)
    21.       {
    22.            // Generate the setting entity
    23.            Entity settings = new Entity("usersettings");
    24.            settings["systemuserid"] = item.Id;
    25.            settings["timezonecode"] = 4; // Pacifit Time (US & Canada) GMT -08:00
    26.            // Generate the request and response of the Update User Setting
    27.            UpdateUserSettingsSystemUserRequest settingsUpdReq = new UpdateUserSettingsSystemUserRequest();
    28.            UpdateUserSettingsSystemUserResponse settingsUpdRsp = new UpdateUserSettingsSystemUserResponse();
    29.            settingsUpdReq.Settings = settings;
    30.            settingsUpdReq.UserId = item.Id;
    31.            settingsUpdRsp = (UpdateUserSettingsSystemUserResponse)Service.Execute(settingsUpdReq);
    32.       }
    33.    }

    The complete reference documentation about this entity:
    https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/entities/usersettings?view=op-9-1 

    Enjoy it!

    Continue reading...



  • D365 CRM: How to build dynamically an Entity Record URL using C#


    If you need to your code to build dynamically an Entity Record URL for the user to access throw the browser, you can use the following code to archive this:
     


    Enjoy it!

    Continue reading...



  • D365 CRM: Metadata Browser for Dynamics 365/Power Apps Extension for Chrome


    Sometimes when you are developing a JavaScript code for an Entity Form or a server-side code for a customization in CRM, you need to know the logical name of the different attributes of the entity to access those in your rule. For this you need to go to a solution that contains the metadata of this entity doing some clicks in your browser to access to this information. But thanks to an extension that you can install in your browser called “Metadata Browser for Dynamics 365/Power Apps” you can avoid all of this and check quickly in a form:

    With extension:



    You can download and install this extension following this link:

    https://chrome.google.com/webstore/detail/metadata-browser-for-dyna/ahbljnhlfdbecefhilipmpnlfldnplpb 

    Enjoy it!

    Continue reading...



  • D365 CRM: Configure Relevance/Dataverse Search in Dynamics CRM


    In Dynamics 365, there is a feature called Dataverse Search (previously known as Relevance Search), which allows a user to search Dynamics 365 data and have it displayed in order of relevance. This feature is powered by Azure Search and uses the same scoring concepts.
    To enable Dataverse Search, go to https://admin.powerplatform.microsoft.com/, select your environment and go to Settings, click on Features, look for Dataverse search and turn ON:

     

    Then go to Dynamics CRM and in the top center of the header enter a word to search in your entity records:
     
    This will display a result of all the records by entity that contains that word in the fields that you configured in the Quick Find View of the entity. There are some common fields, that are part of every table in CRM, which are part of the Dataverse Search index by default. Some examples of common fields are:
    •    ownerid (Name of lookup)
    •    owningbusinessunit (Name of lookup)
    •    statecode (Label of optionset)
    •    statuscode (Label of optionset)
    •    name (Primary name field of any table. This may or may not be the same as the logical name (fullname, subject, and so on) of the table.)

    You can click in the top panel which entity to display:

     

    In the right you can expand the Filter panel with the ability to filter further:

     

    To ensure which entities are used by the Dataverse Search, you need to use the legacy solution explorer (if you using Power Apps US Government environment). Go to Customizations and select Entities. You will see Configure Dataverse Search:

     

    Here you can add and remove entities that use Dataverse Search:

     

    Take a look of the bottom bar, you have a limit of fields to index in your environment.

    Original Source:
    https://carldesouza.com/how-to-use-relevance-search-in-dynamics-365/ 

    Official Documentation:
    https://docs.microsoft.com/en-us/power-platform/admin/configure-relevance-search-organization

    Enjoy it!

    Continue reading...



  • D365 CRM: Data Export Service (DES) is deprecated. Use Azure Synapse Link for Dataverse


    In past November 2021, Microsoft announced the deprecation of Data Export Service (DES); an add-on features available via Microsoft AppSource which provides the ability to replicate data from Microsoft Dataverse to an Azure SQL store in a customer-owned Azure subscription. Data Export Service will continue to work and will be fully supported until it reaches end-of-support and end-of-life in November 2022.
    What is Azure Synapse Link for Dataverse?
    Azure Synapse Link for Dataverse enables you to get near real-time insights over your data in Microsoft Dataverse. With a few clicks, you can bring your Dataverse data to Azure Synapse, visualize data in your Azure Synapse workspace, and rapidly start processing the data to discover insights using advanced analytics capabilities for serverless data lake exploration, code-free data integration, data flows for extract, transform, load (ETL) pipelines, and optimized Apache Spark for big data analytics.
     


    Azure Synapse Link for Dataverse is the fastest path to success for you to analyze data and generate insights as your experiences are ready to run as soon as you launch your Azure Synapse workspace.
     


    If you need help to migrate this configuration, Microsoft put the Data Export Service Deprecation Playbook to help you to move to Azure Synapse Link for Dataverse. The playbook will guide you through the initialization, planning, and adoption phases:

    https://aka.ms/DESDeprecationPlaybook

    While Data Export Service will continue to work and will be fully supported, Microsoft will not be adding any new features until it reaches end-of-support and end-of-life in November 2022. Is recommended to ACT NOW and START PLANNING the onboarding process to Azure Synapse Link for Dataverse.

    Official Documentation:
    https://docs.microsoft.com/en-us/power-apps/maker/data-platform/export-to-data-lake

    Original Source:
    https://powerapps.microsoft.com/en-us/blog/do-more-with-data-from-data-export-service-to-azure-synapse-link-for-dataverse/ 

    Enjoy it!

    Continue reading...



  • D365 CRM: Make your charts 3D in CRM


    Have you ever thought that your charts in Dynamics CRM would look way cooler if they were three-dimensional? If your answer is yes, then you will be thrilled to know that there is an easy way to do this without needing to know how to code. In today's blog, we will go through the steps needed to improve the look of your charts in minutes.
    -To get started, you will first want to open the existing chart that you want to make 3D in the chart pane. Go to a solution, select the chart and Export it:



    -Next, you will need to save the xml file of the chart to your Desktop. Once you have saved the file to your Desktop, you will want to select the xml file and open it in Visual Studio or Note Pad. Once open it should look something like this:

     
    -Now you will need to change an area of the code in order to make the chart 3D. Toward the bottom of the code, you will see the line (see highlighted box in the image above). Next, delete "false" from the line of code and replace it with "true". In case that tag not exists, add it by hand. Your line of code should now look like this:

     

    -Save your changes and then go back to the chart in your solution and select Import Chart.  
    -Select the xml file that you changed and then import the file.
    -You can replace it or create a new one. Publish the customizations and take a look of the results:

     

    Original Source:
    https://microsoft-business-applications.hcltech.com/tips-and-tricks/easily-make-your-charts-3-d-in-dynamics-crm/ 

    Enjoy it!

    Continue reading...



  • D365 CRM: Customize the colors of your charts in CRM


    At times it can be nice to define you own colors in charts. You may need to use a specific a corporate color scheme, make it easier to tell certain items apart or simply make the chart easier for the user to understand quickly.
    -To get started, you will first want to open the existing chart that you want to change the color in the chart pane. Go to a solution, select the chart and Export it:

     

    -Next, you will need to save the xml file of the chart to your Desktop. Once you have saved the file to your Desktop, you will want to select the xml file and open it in Visual Studio or Note Pad. Once open it should look something like this:

     

    - All the colors are listed as RGB colors, separated by a semicolon. While Dynamics CRM add RGB colors to its custom palette it should be noted that Dynamics CRM accepts:
    •    RGB Decimal (example: 97, 142, 206)
    •    RGB HEX (example: #4169E1)
    •    Named colors (example: Blue)
    •    ARGB (127, 97, 142, 206)
    The named colors could prove a lot easier to work with.
    So instead of PaletteCustomColors=”97,142,206; 209,98,96; 168,203,104; etc. we could write PaletteCustomColors=”Blue; Red; Green; etc.
    Using the color names also makes it a lot easier to check if you have added them in the correct order.:
    This page contains an overview of the named colors available to use in charts:
    http://msdn.microsoft.com/en-us/library/aa358800.aspx 
    There’s one color missing from this list and that is “Transparent”. Transparent is very handy when you need to add data to a chart, but actually don’t want to show it. For example, you may only want to display the value on a chart, but not have the bar or column visible.
    Back to the example where we wanted to change the color scheme to Red, Green and Blue.
    To achieve that we need to edit the XML files so the first the colors of the PaletteCustomColors look like this:

     

    -Save your changes and then go back to the chart in your solution and select Import Chart.
     
    -Select the xml file that you changed and then import the file.
     
    -You can replace it or create a new one. Publish the customizations and take a look of the results:

     

    Original Source:
    https://crmchartguy.wordpress.com/2012/08/23/palette-custom-colors-in-charts/

    Enjoy it!

    Continue reading...



  • D365 CRM: Set the Entity Image on an Entity in Dynamics CRM using C#


    When you create a new entity record supported with Entity Image, by default will appear like this, with two letters that contain in the primary name field:


     
    If you like to change that image using the SDK API, you need to set the attribute “entityimage” with a valid byte array of an image file. It is recommended by Microsoft to use a 144x144.png for best results. Other viable dimensions are: 60x80, 144x400, 400x500, 400x144.

    Here a sample code:

    -Using Base64 image:

    1.    Entity updateAccountImage = new Entity("account", accountId);
         
    2.    updateAccountImage["entityimage"] = Convert.FromBase64String(base64img); // Base64 of the image file
         
    3.    service.Update(updateAccountImage);

    -Using Byte Array image:

    1.    Entity updateAccountImage = new Entity("account", accountId);
    2.    updateAccountImage["entityimage"] = File.ReadAllBytes(fileName); // Byte[] of the image file in disk
         
    3.    service.Update(updateAccountImage);

     

    Original Source:
    https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/sample-set-retrieve-entity-images?view=op-9-1

    Enjoy it!

    Continue reading...



  • D365 CRM: Show emojis in a Home Page Grid view of an entity


    If you have in your entity a column that maybe can be represented by images like emojis, CRM has a feature to archive this. Let’s take this example of this custom field:
     


    This is a custom Option Set field called Relationship with the options Good Relationship, Neutral Relationship and Bad Relationship. We thing that this field value will be better represented by emojis icons. To archive this, we will need:
    -A custom Option Set field with the options:

     

    -Three Web Resources of type PNG or GIF (for transparency background) with the emojis.
    -Another Web Resource of type JavaScript that executes the code to convert the options in the emojis.

     

    The JavaScript code is:

     

    This code will execute in each row of the current page of the grid, get the value of the option set field and replace with the target image of the emoji.
    To finish this, we need to go to the target view of the entity to customize, add the Option Set column, click Change Properties, select the JavaScript Web Resource and enter the Function Name:

     

    Click OK, Save and Publish the customizations. The result:



    Enjoy it!

    Continue reading...