👋🏾 Looking to join our SuiteCRM Community Working Group? 💌 Open invitation throughout January. Check out all the details here 👈

Run Javascript after DetailsView fully loaded


I added a javascript file to the leads custom\modules\Leads\metadata\detailviewdefs.php

The js file loads fine but it loads with the initial page load. I need to attach events (call functions etc) when the lead details are fully loaded (Ajax panels are loaded).

Is there an event that gets fired that I can consume?

Only thing I found is related to SugarCRM but that didn’t work.


hmm, actually it seems to be loading as part of the ajax response but firing twice.

Sure, we use this:

// We load our code once everything else is loaded

done = runCheckInterval();
function runCheckInterval() {
    var checkIfSearchPaneIsLoaded = setInterval(function () {
        if (SUGAR_callsInProgress === 0) {
            result = yourCode();

            return result;
    }, 200);
1 Like

Many thanks for that.

I ended up doing exactly that. Although yours is checking SUGAR_callsInProgress. so I will switch to using that.

I did find that the JS runs twice. I think there could be a bug. I will look at raising it once I have more time.

I did a bit of a hack to get things working. Because in my page, the JS file gets triggered twice, I had to schedule the runCheckInterval ( initialiseLeadsNotes) , randomly. So only one call is successful. Rest of the code is similar to what you have posted.

var delay = Math.floor(Math.random() * 2000);
SUGAR.initialisedCalled = true;

1 Like