Posts

DYNAMICS 365 HOW TO COPY PASTE BUSINESS RULES COMPONENTS

Image
Last day, I was working with Business Rules and one of them was quite large and contains many conditions and actions. To speed up my creation of this business rule, I used the Copy/Paste components in Business Rules that exists out-of-the-box. So I decided to write a post about it and share my thoughts. For the sake of this post, I will create a new business rule against the Account entity. This business rule will show/hide fields and make them required based on the Relation Type field. Therefore, similar conditions and actions will exist in order to achieve this requirement. Let's start by setting the initial condition Next, in the right pane, Drag/Drop the components Set Visibility and Set Business Required to the True part of the condition and set t...

DYNAMICS 365 HOW TO CHECK IF BUSINESS PROCESS FLOW (BPF) EXISTS ON A RECORD

Working with Business Process Flows is very popular and requested for many scenarios. But it is sometimes tricky especially when you have some treatment to do in JavaScript. Some of these scenarios might be changing the BPF phase if a field is set to a specific value or show/hide fields/tabs based on the BPF phase ... that require some JavaScript code in order to achieve them. For some developers, it is straight forward to capture the process stage by entering the following lines of code. var stage = formContext.data.process.getActiveStage(); var stageName = stage.getName(); if (stageName == "<somevalue>") { //Do something } This is enough and will perfectly work for new records, since the BPF will be automatically assigned to the record. However, for old records that exist before...

ADD PEN CONTROL TO CAPTURE CUSTOMER SIGNATURE ON THE FORM

Image
Many people don't know that Pen control exists as a Out of the box feature in Dynamics 365. The Pen control will allow the user to capture customer signature on a record, and it is available for both built-in and custom entities. In this post, I will go through the steps and show you how to Add and Use the Pen control in Dynamics 365 forms that allow you to capture the customer signature . For the sake of this post, I created a multi-line field in the Account entity and you can follow the below steps to enable the Pen control to capture the customer signature . Put the field in a specific form section Open the Fields Properties > Formatting tab and set the number of rows for better appearance (i.e: 5) Go to Controls tab > Add Control ...

DYNAMICS 365 CREATE AUTO-NUMBER FIELD WITHOUT CODE

Image
Auto-numbering was, is, and will stay a main request to a lot of organizations when it comes to records' uniqueness whether working in Sales, Customer Service, or any other area. As for the consulting company, auto-numbering was a development task, where the developer has to write a bunch of code and test it in order to achieve this mission. However, in PowerApps and CDS, you can now create auto-number fields without writing a single line of code. Login to your PowerApps maker https://make.powerapps.com and open the solution you are working with Open the entity you want to create the auto-number field and create new field Note: I am using the Account entity, but you can use any entity In the right Pane, select the Data Type dropdown > A...

DYNAMICS 365 ADD EMOJIS IN OPTION SETS

Image
How professional to provide the end users, a user-friendly and easy interface, as well as meaningful and comprehensive layout. Sometimes, you think that showing a visual effect is a better and more interesting way to help users in their daily work. Here comes our topic of today, which is adding Emoji in Dynamics 365 and more specifically making the option-sets fields more attractive by displaying emojis in the option-set items . This post will show you how to add emojis in Option-sets fields so you can make more attractive and pretty visual. All you need is to simply get your emojis from a website like https://getemoji.com and a copy/paste into your option-set field. For the sake of this post, I created a new option-set field Customer Satisfaction on the case entity that contains the below options: Very Satisfied ...

HOW TO CONNECT TO DYNAMICS 365 ENVIRONMENT WITH OAUTH AUTHENTICATION

Image
Previously, we were applying the Office 365 authentication method to connect to the D365 environment by using the Dynamics 365 URL , User Name and Password in order to build the connection string and create the CRM Service as per the below sample. string connectionString = "Url=" + Url + "; Username =" + UserName + "; Password=" + Password + "; authtype=Office365"; CrmServiceClient crmService = new CrmServiceClient(connectionString); However, Microsoft has announced the deprecation of the Office 365 connection and declared to connect to Dynamics 365 with Oauth authentication method instead. In this blog post, I will detail the needed steps that should be followed to connect to the Dynamics 365 environment using the OAUTH authentication . Below are the three areas we have to configure for the OAUTH A...

DYNAMICS 365 CALL CUSTOM ACTION FROM JAVASCRIPT AND C#

Image
In another post, we saw how to call workflows from JavaScript and C# . In this post, I will show you how to call a Custom Action from JavaScript and C# . For the sake of the post, I created a simple custom action against the Account entity with two input parameters and one output parameter. This action will create a task record and set the Subject field to Task created by custom Action from JavaScript after calling the action from JavaScript Task created by custom Action from C# after calling the action from C# Below is the end result after calling the action from JavaScript Below is the end result after calling the action from C# The below function calls the...

DYNAMICS 365 CALL WORKFLOW FROM JAVASCRIPT AND C#

Image
In another post, we saw how to call custom actions from JavaScript and C# . In this post, I will show you how to call workflows from JavaScript or C# and to accomplish this, you need two parameters: The Workflow Id that you want to call AND The Record Id that the workflow will be executed against For the sake of the demo, I created a workflow that will set the Account Name field to: WF Called and Updated From JavaScript after calling the workflow from JavaScript WF Called and Updated From C# after calling the workflow from C# Below is the end result after calling the workflow in JavaScript Below is the end result after calling the workflow in C# ...

DYNAMICS 365 HTML WEB RESOURCE WEB INTERFACE VS UNIFIED INTERFACE

In this quick post, I will talk about two differences between the Web Interface and the Unified Interface when opening a HTML Web Resource in a new window . These two differences are: Refresh the D365 opener of the html web resource Close the opened html web resource In the Web Interface, we normally use the below functions to achieve the needed action: Refresh the D365 opener: opener.location.reload(); Close the opened html web resource: window.close(); However, with the arrival of the Unified Interface, slight changes started to arise, especially for the JavaScript. Some of them are for the above actions. Using the same JavaScript functions for the Unified Interface will not work. Fortunately, we c...

DYNAMICS 365 HOW TO FILTER OPTION SET IN CLASSIC WEB INTERFACE AND UNIFIED INTERFACE

Image
I will talk about an issue when adding options to an option-set field using JavaScript. Therefore, in this post, we will see how to filter Option set fields in Web Interface and Unified Interface . The issue will appear in the Unified Interface when: The option-set field is used in the Web Interface AND the Unified Interface The option-set field is added to the form header The options are added dynamically using JavaScript In my below example, I am using two option-set fields I added the fields to the entity form and the header form I added a JavaScript function on change of the Parent Option Set field to filter the Child Option Set based on the selected option ...

DYNAMICS 365 HOW TO FORCE RECALCULATE ROLLUP FIELDS

In this quick Blog post, we will see how to force recalculate Rollup fields in JavaScript and C# using the below functions. Recalculate Rollup field in JavaScript (for account entity) function reCalculateRollupField(entityPluralName, recordGuid, rollupFieldName) { recordGuid = recordGuid.replace("{", "").replace("}", ""); var requestUrl = Xrm.Page.context.getClientUrl() + "/api/data/v9.0/CalculateRollupField(Target=@tid,FieldName=@fn)?@tid={'@odata.id':'" + entityPluralName + "(" + recordGuid + ")'}&@fn='" + rollupFieldName + "'"; var HttpReq = new XMLHttpRequest(); // Double Check the API URL HttpReq.open("GET", requestUrl, true); ...

DYNAMICS 365 HOW TO SWITCH BETWEEN UNIFIED CLIENT INTERFACE (UCI) AND CLASSIC WEB INTERFACE

Image
Due to many questions in the Dynamics community on how to switch between the new Unified Client Interface (UCI) and the Classic Web Interface , I decided to write this post to show you how to do it. In the new V9 version, the default interface will be rendered in the Unified Client Interface; however, many users still prefer the original one and need to switch back to the classic web interface. You have two options to switch between the new Unified Client Interface (UCI) and the Classic Web Interface From the advanced settings section Click the Settings gear icon > Advanced Settings Click Settings > Administration > System Settings ...

DYNAMICS 365 HOW TO RETRIEVE MORE THAN 5000 RECORDS IN C#

Image
In this post, you will see how to retrieve more than 5000 records from CRM/D365 entities in C# . To do this, I imported thousands of records into the contact entity Created a console application From the Main method, called the two methods: RetrieveMultiple : It will use the Service.RetrieveMultiple request RetrieveMultipleRequest : It will use the RetrieveMultipleRequest message Ran the console application that will give the below result The RetrieveMultiple method is limited to retrieve 5000 records maximum and will look as follows. public string RetrieveMultiple() { EntityCollection objCollection = new EntityCollection(); ...

DYNAMICS 365 FILTER LOOKUP FIELD BASED ON N:N RELATIONSHIP

Image
How to filter a Lookup field based on a N:N relationship of a parent entity using JavaScript . To show you this, I will use the Account entity, the Contact entity, and a custom entity Conference . The contact entity has a N:1 relation with the account entity (lookup field) The contact entity has a N:1 relation with the conference entity (lookup field) The account entity has a N:N relation with the conference entity (sub-grid) I need to filter the conference lookup of the contact entity to list The conference records that are related to the contact parent account or The conference records that are not related to any account Based on the above conditions, the users will not be able to ch...