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 CRM (Archived)

Calling wrong web-Resources

(0) ShareShare
ReportReport
Posted on by

Recently i faced an issues where my js function calling wrong web resources.

Well i have(wbr1,wbr2) two web resources with the same function name(call_wbr()) i have registered the function only for wbr1 during onload but it calling the function present in wbr2. Even though i have the registered for the right one it still call the wrong web-resources.

i cant remove the wbr2 from the library because it is used in the form,and if i try change the function name which  difficult to find and replace for all form.

So how can i resolve this?    

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Michel van den Brink Profile Picture
    4,697 on at

    Hello,

    When you add multiple script libraries (webresources) to a form, they will all be loaded into the form's scripting environment equally. Even if you don't register any event handlers (like onload) the script will still be loaded.

    If you have any function names that are the same, across multiple scripts (webresources), this will always be an issue, because all the scripts will be loaded and in the form, it can now not correctly distinguish which function it should call, so it calls the last one loaded.

    This is more of a JavaScript issue, rather than a Dynamics 365 (CRM) one, in JavaScript , within the same scope, you can't have multiple functions with the same name, because the last one loaded will overwrite the first one loaded.

    You can try swapping the order of your script libraries, how they are loaded, to make sure that 'wbr1' is loaded last, so it's method will be the winner and overwrite the one from 'wbr2' - this is not really a long term solution but, might help you right now.

    ----

    For the long term, I really recommend that you make your function names unique, across your scripts. Consider using JavaScript namespaces, to ensure that there are no collisions between your function names or worse... between your function names and the function names of another solution.

    Namespaces in JavaScript (roughly) work like this - they isolate your code from all the other code:

     // Create the namespace if it doesn't exist, or keep the existing one:
    var MyCompany = MyCompany || {};
    
    MyCompany.my_function = function() {
       // Your Function Code
    };
    
    MyCompany.my_function2 = function() {
       // Your Function Code
    };

    Then in your form, you can register your onload like this:

    my_5F00_function.png



    Hope this helps you :-)

    - Michel

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 CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans