Clicking on Lookup value navigating you to a different page. Well no more! Control this behavior with the new addOnLookupTagClick function in 2020 Release preview 1


With every release of Dynamics 365, there is something always new for developers. In my last blog I explained about the enhancement in Xrm.WebApi.navigateTo method. Today we will discuss in detail about the new “addOnLookupTagClick” method introduced in Release wave 1, 2020.

So what does this function do? Actually it solves a long standing problem where clicking on a lookup value, it redirected to the lookup record form. A potential problem with this is the user would lose context of the record they are working on. But now this can be avoided. So let’s see how we can achieve the same.

For this demo I use the Account form, Parent Account (parentaccountid) field.

In the onload of the Account form, I add the below code.

e.getEventArgs().preventDefault(); // disable the default behavior which to open the lookup record. 
// get the lookup record value 
var lookupRecord = e.getEventArgs().getTagValue(); 
// get formContext 
var fc = e.getFormContext(); 

The two most important part of the code are already highlighted inside the function with comments. The first one is to prevent the default behavior which is navigating to the lookup record.

The next one is even more important which allows you to select the lookup record clicked. I used the developer tools to show you the format of data returned by function.

The final line of code is to get the form context.

So what actually we can achieve with this. Well a lot. You can open up the lookup record form in a dialog as I explained in my previous blog.

Or may be you can open up a webresource to show up anything. I mean anything that your customer need to want.

Debajit Dutta

(Dynamics MVP)

For consultation/ training visit or reach out to us at


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s