Design a site like this with
Get started

Restrict users from selecting past date (Date Validation)

Let’s learn how to restrict user form selecting past date. We can do this through JavaScript.

Below we have a Lead form, where we have a Target Date field. The need is to restrict user from saving the lead form having passed data on Target date field.

Lead Form

Below is the code which can we used:

(function () { }(window.BankNotes = window.BankNotes || {}));
(function (BankNotesFilter) {
/* Function ValidateTargetDate: This would trigger on OnChange event of Target Date field. Which would restrict user from selecting past date under Target Date field.*/
BankNotesFilter.ValidateTargetDate = function (executionContext) {
var formContext = executionContext.getFormContext();
var dateFieldVal = formContext.getAttribute("blog_targetdate").getValue(); // TargetDate Field
var today = new Date();
var todaydate = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0);

if (dateFieldVal < todaydate) {
formContext.getControl("blog_targetdate").setNotification("Selected date should be greater or equal to today","101");
else {
// alert("Selected Target date greater than today");
}(window.BankNotes.BankNotesFilter = window.BankNotes.BankNotesFilter || {}));

The code restrict user from selecting past date on Target Date field.
If, user select past date under Target Date field then the field value will be cleared out showing notification(“Selected date should be greater or equal to today”) on the field.

Just, we need to call the above code on OnChange event of Target Date field:

Call the Function: BankNotes.BankNotesFilter.ValidateTargetDate

The value will be cleared out, on selection of past date

When a user select today’s or any future date, system will allow user to select the date.

User able to select any future/current date.

Hope this helps!


Filter LookUp: Set Regarding Lookup Entities

Let’s learn how to set entities under lookup field.

Let’s take an example of Regarding lookup of Task activity.

In the below image we can see that the regarding lookup contains multiple entities associated with it where a user can go and select any entity records.

Task Entity: Regarding lookup

To restrict “Regarding” lookup entities, we can use java script which would help us in populating only the needed entities.

(function () { }(window.LearningRefresh = window.LearningRefresh || {}));
(function (LearningRefreshFilter) {
LearningRefreshFilter.FilterRegarding = function (executionContext) {
var formContext = executionContext.getFormContext();
formContext.getControl("regardingobjectid").setEntityTypes(["contact", "incident", "account"]); //Regarding Lookup Field
}(window.LearningRefresh.LearningRefreshFilter = window.LearningRefresh.LearningRefreshFilter || {}));

We will need to call the java script “OnLoad” event of the Task activity main form.

The calling function should be LearningRefresh.LearningRefreshFilter.FilterRegarding

Save and Publish the changes.

Filter Regarding Lookup

Hope this helps!

Filter Lookup Based on Option Set value

Today, I met with a requirement where we need to achieve filtering of lookup values based on option set value selection.

The requirement was to filter Loan Category(lookup field), based on Loan Type(optionset field).
There were three different types of Loan Types in the system (optionset field).

  • Home Loan
  • Business Loan
  • Personal Loan

I had to provide the required filter on “Lead” entity. So, below are the steps which I followed.

  • Created a Global OptionSet, having Loan Types.
  • Created a field Lead Loan Type(blog_leadloantype) of option set type on Lead entity and called the Global Option Set
  • Created a field Lead Category(blog_leadcategory) of lookup type on Lead entity. Which have a relationship with one of our custom entity name Bank Code.
  • Created a field Loan Type(blog_loantypes) of option set type under Bank Code entity. (required for filtering values)

Below is the screenshot of Bank Code entity, from advanced find which show the data to be filtered in the below desired format.

Advance Find on Bank Code entity

Create a new webresource of Javascript type and paste the below the code in the editor:

(function () { }(window.BankNotes = window.BankNotes || {}));
(function (BankNotesFilter) {
BankNotesFilter.onCategoryChange = function (executionContext) {
var formContext = executionContext.getFormContext();                                  
//Check if the field is not null
if (formContext.getAttribute("blog_leadloantype").getValue() != null) {

//Apply Search on lookup field OnClick 
var loancode = formContext.getAttribute("blog_leadloantype").getValue();        

//Apply the filter condition
var filter = "<filter type='and'><condition attribute='blog_loantypes' operator='eq' value='" + loancode + "' /></filter>";

//Populate the filter values into lookup field
}(window.BankNotes.BankNotesFilter = window.BankNotes.BankNotesFilter || {}));

The above script will triggered on the onChange event for Lead Loan Type(blog_leadloantype). Function which needs to be called – BankNotes.BankNotesFilter.onCategoryChange

I hope this helps you. 👍

Omnichannel for Customer Service – Masking Chat Conversation

Omnichannel for Customer Service offers us the capability to mask chat data.

Why use data masking?

Data masking helps the organization to protect the customer sensitive data like Credit card details, SSN number, Account Number, etc.

How does it help any use case?

Any text that’s masked in a conversation will also be masked in the conversation transcript.

Masking rules can be implemented for customers, agents, or both.

Let’s start with setting up a masking rule, follow the below steps:

  • Go to Omnichannel Administration App
  • Under site map go to Settings –> Data Masking Settings
  • Enable Mask private customer data from the agent
  • Create a masking rule
Omnichannel Administration: Masking rule page
  • Mask private agent data from the customer: Data the agent sends is masked for both the customer and agent for live chat and async channel messages.
  • Mask private customer data from the agent: Data the customer sends is masked for both the customer and agent for live chat, but only for the user interface of the agent when using async channels.

For the masking rule to work, we need to Activate the desired rule.

Create New Masking Rule
Masking rule needed Regular Expression for masking the data.

Only 10 data-masking rules, including the rules provided out of the box, can exist in Omnichannel for Customer Service.

Let’s create a simple masking rule where the rule would mask(#) any incorrect word send via customer chat to our agent.
I have entered the few incorrect words inside the regular expression field. Now, if the customer enters any words(shit|donkey|fool|useless|angry|sue) which lies within this Regular Expression the word would be masked by “#”

Create Masking Rule

Name: Enter the masking rule name
Description: Provide the description of the created rule
Regular Expression: Regular Expression is required for masking data

Going to the portal, User-initiated the chat and type the incorrect word on the chat window.

Following the same chat, refer to the below slide.

I hope this helps!!!

Add related entity view on the Main Form

Today will learn how to populate the related associated entity in the main form.

I have a Contact entity and it has a (1:N) parental relationship with the entity “Signs & symptom“. The aim of this blog is to populate the Signs & symptoms next to the Summary tab so that the number of clicks gets limited.

Figure 1: Contact Form
Figure 2: Signs & symptoms related entity.

Let’s navigate to the Contact entity form editor. There we will have to add a new tab just below the Summary tab.

Figure 3: Adding new tab on Contact Form, below Summary tab.
Figure 4: Add label to the tab as “Signs & symptoms”.

Now, we will add a sub-gird inside the Signs & symptoms tab.

Figure 5: Add Sub-Grid to Tab

Then we will set the properties of the sub-grid by providing it a name, label. We will also do the entity and view mapping.

Figure 6: Set Properties of a section
Figure 7: Entity Mapping and selecting the default view

Once this is done. Hit the OK button and publish the changes.

Figure 8: Contact related entity “Signs & symptoms” populate next to Summary tab

In the above image, we can see that the Contact related entity “Signs & symptoms” populates next to the Summary tab.

By clicking on the Signs & symptoms tab we would get the same associated view which we would get when we navigate from related to Signs & symptoms.

Hope this blog helps you.

Mobile Timeline: Activate Camera feature under timeline from Dynamics 365 for Phone Mobile App

Taking a picture from Dynamics 365 mobile app and attaching it on the timeline at the same time is now possible.

We will just have to enable few setting from mobile app. Here are the step to follow:

Login to the mobile app using admin credential and go to Setting –> Mobile Setting

Below screen would appear after clicking on Mobile Setting. Enable Allow Access under Camera. If we want to save the picture taken from the phone into the phone gallery then, we also need to enable Save Photo to Library option. Hit the OK button.

Enabled the Camera feature from timeline

Now. let navigate to Opportunity. I have opened a record under opportunity.

Now, we see that the note has got saved under timeline of “Adobe Opportunity” record .

Thanks for reading the blog.

Generate Auto Number for entity without code in D365 CRM

We all know that Microsoft has the auto-number feature, but it has its own prefix for auto-number and its own sequence for generating auto number.
There are many ask from the users that the auto number for an entity should have their org name as a prefix and the random number should be in a particular format.

Today, let’s learn how to implement the auto-number functionality for an entity with the prefix required by business user.

Before we start we should have D365 System Admin rights with us.

Login to D365 CRM online and Navigate to Power Apps portal.
Below is the Power Apps Home page. Click on Data, which gets expanded and show us the entities currently present under the logged in CRM Instance.

Figure 1: Power Apps Home Page

Select the desired entity, I am selecting Account entity.

Figure 2: Select Account entity

The below tabs under the yellow box are the one from where we get to know about the Fields, Relationship, Business Rule, Views etc. present under Account entity.

For achieving the Auto Number functionality, we will create a new field by clicking on “+Add field” button.

Figure 3: Entity details and adding new auto number field

Provide Display name to the field and change the datatype to “Autonumber”.

Then let’s change the value under “Autonumber type” field to Custom. Under Format field we can use custom auto number format.

Seed value is by default 1000, we will be using the same.

Depending on the combination of Format and Seed field. We get the sample output under Preview.
Now, hit the “Done” button.

Figure 4: Create Auto-Number field

Click on Save Entity.

Figure 5: Save the changes done on entity

Now, let’s navigate to our CRM screen and open the Account entity under customization where we can decide where to place the newly created autonumber field (Acc Account Number) on the Account Form and Publish the change.

Figure 6: Field placed on the form, hit the save and publish button.

Going to Account entity and creating a new account. When clicking on Save, we get to see that a random auto number got populated under the Acc Auto Number field.

Figure 7: Auto Number generation

Hope this helps you. Enjoy D365 CRM!

Microsoft Release 2020: Features (Template Access)

Continuing to the Microsoft Release 2020 features (Previous post: Kanban View feature)
Let’s learn about another new feature which make the users life easy while selecting the template.

  • This feature is available in the Unified Interface only.
  • This capability is available in Dynamics 365 Sales Enterprise and Dynamics 365 Sales Professional.

We have seen in sales organizations that when CRM is implemented, then there are multiple scenario where users need to select templates for notifying there customers.

Then comes a situation where user needs to decide which available template to select and most relevant one. Before wave 1 release 2020, user didn’t had the option to view the template body of the selected template without being redirected to another screen.

Let’s jump and demonstrate the feature.

  • Go to Email template
  • Provide the customer name to whom the email needs to be sent
  • Click on Insert Template button on the ribbon
Figure 1: Insert Template

Now, user will get the access to list of all available email templates from which user needs to scroll and find the most relevant one among them.

This feature helps the user to look on the template content on the same screen and make decisions while selecting the template.

Figure 2: Email Template body
  • Hit the Apply template button.
Figure 3: Template applied.

Now, we see that the selected email template Subject and mail body has been auto-populated under the email activity.

Hope this post helps in understanding the email template feature.

Microsoft Release 2020: Features (Kanban Control)

With the very latest Microsoft D365 Release 2020, Microsoft has come up with many new feature among which one is Kanban.

I will directly start with Kanban feature, how to enable it and it’s use.

To get the Kanban view feature, first we need to ensure that our environment has got the 2020 release wave 1 enabled. To check whether our environment is updated with Microsoft 2020 wave 1 release or not, we need to follow few steps.

Please follow the steps provide by Microsoft to enable the early access of Microsoft 2020 Wave 1 Release.

We have got our environment updated with the wave 1 release.

Let’s jump into enabling the Kanban feature for Opportunity entity. To achieve this feature we need to enable the Kanban control under Opportunity entity.
Step 1: Go to Opportunity entity
Step 2: Click on Controls tab

Figure 1: Click on Controls tab under Opportunity entity.

Step 3: Now click on Add control –> Serach for Kanban –> select Kanban and hit the Add button.

Figure 2: Adding Kanban control to Opportunity entity.

Step 4: Select the Kanban control for Web, Phone and Tablet option. This help us in maintaining a consistent view across all the devices.

Figure 3: Enabling Kanban view.

Step 5: Save and Publish the changes.

Now, Let’s navigate to Opportunity entity.
Here is our new Kanban view, where user has an two Kanban type option:

  • Status
  • Business Process Flow

Currently, I have opened the Open Opportunities view where the Kanban Type is Business Process Flow.
I see that Microsoft has provided their users a flexibility to segregate their opportunities depending on the business process flow stages the opportunities are currently residing.

Figure 4: Kanban View of Open Opportunities Kanban Type: Business Process Flow.

Now, lets open All Opportunities view where the Kanban Type is Status.

Figure 5: Kanban type is set to Opportunity Status
Note: If you are unable to find the Kanban feature after updating wave 1 release 2020. You need to click on the ribbon and select Kanban.
Figure 6: Kanban

Hope this helps!!!

Calling Namespace Javascript function in Dynamics CRM

I still see many people have some issue in understanding/calling namespace Javascript function.

Below pattern is a simple way of writing a Javascript in Dyanmics CRM, which most of the people are familiar with:

function MessagePopUp(executionContext)
 var formContext = executionContext.getFormContext();
 var email = formContext.getAttribute('emailaddress1').getValue(); 
 alert('Welcome mail sent to ' + email); 

Now, the namespace format, which is recommended by Microsoft. To avoid conflict within the functions name.

var Namespace = window.Namespace || {};
 function (){
 this.formOnLoad = function(executionContext)
 var formContext = executionContext.getFormContext();
 var email = formContext.getAttribute('emailaddress1').getValue();
 alert('Welcome mail sent to ' + email);

In the above code we have declared the variable as “Namespace”. The same should be called at the end of the function as .call(Namespace).

this.functionName = function(executionContext) /* In namespace notation javascript function should be called using this keyword, */

For calling a above namespace notation javascript, we need to call it as Namespace.formOnLoad on the event handler.

Figure 1: For calling formOnLoad function we need to use Namespace.formOnLoad
Figure 2: Screenshot from Event Handlers

Save and Publish the code.

Refreshing the contact entity page and we will get the message pop-up on form onload.

Figure 3: Message Pop-Up

Hope this blog help in understanding Namespace Notation Javascript!!