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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

HTML Web Resource loaded twice

(0) ShareShare
ReportReport
Posted on by

I customized a Form in CRM by adding a web resource (HTML). On the load of the weg page, i'm calling a javascript function.

For some unknow reason, CRM is loading the web resource twice causing the Javascript function to be called twice as well. Is this a bug and is there a way to prevent that to happen?

I noticed that this behavior is only happening on a CRM Online SANDBOX instance. I tried that exact same code on different CRM (2013, 2015, 2016, Online) and thw web resource is only loaded once.

Any ideas?

*This post is locked for comments

I have the same question (0)
  • Bas van de Sande Profile Picture
    4,383 on at

    Hi Yannic,

    do you happen to have a javascript function registered twice on the onload event?

    Or does the javascript function you use call another function that loads the resource?

    Bas

  • Community Member Profile Picture
    on at

    Nothing is registered twice. With a break point in my web resource, i validated that the body=onload is called twice by CRM. What is strange is that this is only happening in one environment (CRM Online Sanbox). I tested the exact same thing in at least 3-4 other enviroments and the web resource is only loaded once.

  • Community Member Profile Picture
    on at

    body=onload?

    have you tried window.onload?

    probably the same result though, but could be worth a try. there's also document.onload I guess.

  • Suggested answer
    Bas van de Sande Profile Picture
    4,383 on at

    Hi Yannic,

    one question: have you compared the form rendering methods between environments. I mean are you using turbo forms or legacy forms?

    Bas

  • Community Member Profile Picture
    on at

    Good catch. I didn't thought of that. The "faulty" CRM is still using the Legacy Forms while i'm testing with the new form rendering.

    Thanks for the hint !

    I'll confirm soon if it "fixes" the issue.

  • Suggested answer
    Josh P Profile Picture
    2,895 on at

    So this is an old post, but I came across this recently in version 9 unified interface. Interestingly enough, the issue only happens when the resource has a self-executing function for the window.onload event. I'm not sure why this would be happening, but I hope this helps others that might be having the same issue.

    onload fires twice:

    <script type="text/javascript">

       (window.onload = function () {

           debugger;

           alert("Web resource initialized");

       })();

    </script>

    onload fires once:

    <script type="text/javascript">

       window.onload = function () {

           alert("I'm initialized!! YAY!");

       };

    </script>

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans