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

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

Posted On December 27, 2019 by Admin Posted in 

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 :

Secured By miniOrange