Attach Custom Generic event to lookup field (one or multiple same field) in D365 portals

Sometimes we may get some requirements with multiple lookup fields on the same Entity form on D365 Portals. Also, we may have to perform some operations on click of search button on these Lookup fields. Here, it is not possible to achieve this without writing javascript or jquery code mean-while, we also have to make sure that the click event should be generic (single event working for all similar lookup fields). This blog will guide you to attach generic click event on all the similar lookup field using jquery. Below is the sample code for the same.


$(document).ready(function () {

$(“.genericContact”).parent().find(“button[title=’Launch lookup modal’]”).each(function () {//click for all lookup

$(this).click(function () {

//your  code here




In the above code, selector genericContact is a custom css class added to all the similar lookup fields on an entity form. To see how to add css class to any attribute click here.

Share Story :




Enter your email address to follow this blog and receive notifications of new posts by email.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.