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

  • 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". 

  • 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

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

News and Announcements

Now Available: 2025 Release Wave 2

Quick Links

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

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

#1
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 51 Most Valuable Professional

#2
Ramesh Kumar Profile Picture

Ramesh Kumar 42

#3
David Shaw_UK Profile Picture

David Shaw_UK 27

Featured topics

Product updates

Dynamics 365 release plans