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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Do multiple OnLoad functions on the same form conflict with each other?

(0) ShareShare
ReportReport
Posted on by 365

Hi,

I'm new to JavaScript and debugging client side, and I'm experiencing some issues while debugging, I'm trying to understand whether my code is incorrect or they depend on Crm configuration.

I have multiple JavaScript functions added in the Form Properties of my Entity:

Conflicts.png

So that when I load my entity record form and open the Chrome inspector, I can inspect all of them and debugging.

- First, are there any criteria to decide which of these functions will be run first (in other terms: should I worry about it?) or is totally up to the browser? I noticed that the order I added in the Form Properties doesn't matter: the function onLoad of library 2 runs first.

- Secondly, when I debug FunctionToAddFilter and do a WebApi call, as soon as I step out from the RetrievMultipleRecords asynchronous callback and press Resume Script Execution I'm redirected to the onLoad function of library 2 again. 
If I press Step over Next function I'm redirected to the Pretty-Print minified file.

Why I'm redirected to the previous file instead than being redirected inside the success/error callBackFunction? May it depend on configuration, i.e. having multiple OnLoad functions added to the same form?

This is the complete code, including the asynchronous call:


function myFunction(executionContext) {

    debugger;
    var formContext = executionContext.getFormContext();
    var collectionid = formContext.data.entity.getId();
    var fetchFilter = "";

    Xrm.WebApi.retrieveMultipleRecords("new_movie", "?$select= directorid, new_name&$filter=new_collectionid eq"   collectionid).then(

        function success(result) {
            debugger;
            for (var i = 0; i < result.entities.length; i  ) {
                    var directorid = result.entities[i]["directorid"];
                    var directoridToUpper = directorid.ToUpperCase();
                    var directoridToUpper2 = "{"   directoridToUpper   "}"; // add {} to Guid and letter capitalization                               
                    fetchFilter  = ""   directoridToUpper2   "";
            }
            fetchFilter  = "";
            formContext.getControl("new_defaultdirectorid").addPreSearch(function () {
                formContext.getControl("new_defaultdirectorid").addCustomFilter(fetchFilter);
            })
        },
        function (error) {
            debugger;
            Xrm.openAlertDialog("error: "   error.message);
        }
    );
}

I have the same question (0)
  • Verified answer
    PabloCRP Profile Picture
    1,088 on at

    Hi, Joel D.

    -"First, are there any criteria to decide which of these functions will be run first"

    The excecution order in dynamics firts load Native Code, then custom code from TOP to DOWN on ONLOAD.

    -"Why I'm redirected to the previous file instead than being redirected inside the success/error callBackFunction?"

    remember Xrm.WebApi.retrieveMultipleRecords is a Promise that means that the function you don't know when but sure you will get back a reponse.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 91

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 78 Super User 2026 Season 1

#3
Martin Dráb Profile Picture

Martin Dráb 55 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans