web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Suggested answer

How to capture the on load event of Entity List trigger by search button

(0) ShareShare
ReportReport
Posted on by 92

Hi all,

An entity list will pop up to show all the related entity records by click a search button of a lookup field.  How can I fire javascript when the list is loaded to manipulate the value of name column?  I try this 

$(document).ready(function () {
    
    $("#EntityListControl").on("loaded", function () {
          alert("Yes!");
     // $('#EntityListControl td').filter(function () {
    //  return this.textContent === "SYSTEM"
    //  }).css("color", "red");
 
        });
        
        $(".entitylist.entity-grid").on("loaded", function () {
          
          alert("Yes!");
        });
});

But it doesn't work.   No alert pops up when the list pops up. Can anyone help?

pastedimage1588350995083v2.png

pastedimage1588351013158v3.png

I have the same question (0)
  • Suggested answer
    LeoAlt Profile Picture
    16,331 Moderator on at
    RE: How to capture the on load event of Entity List trigger by search button

    Hi partner,

    You could add your action code into the following code, and add all the code into entity form->"Additional Settings->Custom JavaScript".

    $(document).ready(function () {
    
    $(".genericContact").parent().find("button[title='Launch lookup modal']").each(function () {//click for all lookup
    
    $(this).click(function () {
    
    //your  code here
    
    
    });
    
    });
    
    });

    This code will be triggered when you click on the search icon beside lookup field, and then you could add a "setTimeout" to run your code until the pop up window loaded.

    I used the custom css selector "genericContact" in my code, so you need to add it into form first, go to Entity Form->Entity Form Metadata, add a new record and select your lookup attribute.

    pastedimage1588572515052v1.png

    Fill in the custom style in "Css Class".

    pastedimage1588572540712v2.png

    You could also refer to the following links.

    https://www.cloudfronts.com/attach-custom-generic-event-to-lookup-field-one-or-multiple-same-field-in-d365-portals/

    https://www.cloudfronts.com/add-a-css-class-to-a-field-on-entity-form-on-dynamics-365-portals/

    Best Regards,

    Leo

  • Charlie Chen Profile Picture
    92 on at
    RE: How to capture the on load event of Entity List trigger by search button

    Thank you very much, Leo!

    I used JQuery to register the handler to the click event, searching for the table row count change. And it worked. The only problem is the selector is so ugly:  

     $("#ProfileFormView > div.tab.clearfix > div > div > fieldset > table > tbody > tr:nth-child(3) > td.clearfix.cell.lookup.form-control-cell > div.control > div.input-group > div > button.btn.btn-default.launchentitylookup").click(function () {

    I also tried the method you mentioned, and it worked. The problem is that if I click next on the lookup list to get another page of records, how can I capture the event?

    pastedimage1588599816343v1.png

    My goal is to present the right content of English or French based on if the browser url contains "en-US" or "fr-FR". 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 60

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 19 Super User 2025 Season 2

#3
CU29080825-0 Profile Picture

CU29080825-0 16

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans