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 Webresource not loaded on form when a js function is called from onload event js script ?

(0) ShareShare
ReportReport
Posted on by 217

Hi All,

I have a onload event script on form which is calling a JS function which is part of HTML web resource on the form.

so by the time it is calling a function from html webresource , html webresource is not loaded 

it is throwing crash report on console web browser

HTML-Crash-report.PNG

It is intermittent issue, it works fine for few records 

Any idea on this is much appreciated  ?

Thanks In-Advance

Sainath Pillanagrovi

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Kokulan Profile Picture
    18,054 on at

    Hi

    You could move your script to a separate JS file and add that file to the list of scripts to be loaded on the form properties to get this working.

    If the script that runs on Load of the form uses the UI elements rendered by the web resource, you may have to have a document ready function in your web resource to perform what you are trying to do in Form Load.

  • Sainath Pillanagrovi Profile Picture
    217 on at

    Thanks kokulan for the response , we cannot move the script to separate files.Need to figure out from the existing code

    Please have a look at the script files so that you might get some idea .

    8360.script.PNG

    1261.html.PNG

    When i change the timeout to 10 secs it works fine but waiting for 10 secs is not a good idea.

    Thanks,

    Sainath Pilla

  • Suggested answer
    Temmy Wahyu Raharjo Profile Picture
    2,916 on at

    I think one of the problem (from console log) is you register one of your component as text but u want to load it as CSS?

    For me, that is a very bad idea to refer a javascript function from a html page or something. Better you create a javascript web resource that being called by your custom webres (html) and this form.

  • Suggested answer
    Iswarya Profile Picture
    1,347 on at

    Hi,

    Have u called ur function in your html tag like this

    <body style="word-wrap: break-word;" onload="LoadOptions()">

  • Sainath Pillanagrovi Profile Picture
    217 on at

    No Iswarya , loadoptions will be called from js on load event

  • Iswarya Profile Picture
    1,347 on at

    use above mentioned , it means crm form onload only.

  • Sainath Pillanagrovi Profile Picture
    217 on at

    i got your point but here in my scenario ,we are calling js function with custom parameters so , by just calling on load of html form doesn't satisfy my criteria  

  • Suggested answer
    Vipin J Profile Picture
    1,603 on at

    Hello Sai,

    I see that you are verifying if you getting the control, something like this

    if(context.getcontrol("webresource").getObject != null)

    control might be ready, but the content might not.

    If we can verify if the content of the webresource is ready, then I believe we could handle the given situation.

    See if are getting any specific method in F12 to check wether any that type of method is there.

    Regards,

    Vipin Jaiswal

    [View:https://vjcity.blogspot.com/2019/08/guidelines-to-write-good-javascript.html:750:50]

  • Suggested answer
    Vipin J Profile Picture
    1,603 on at

    Or can we declare a dummy hidden HTML attribute on your HTML webresource and have a while loop which continuously check (with settimeout to 1 second interval) if we are getting that dummy HTML attribute

    Xrm.Page.getControl(webResourceName).getObject().contentWindow.window.document.getElementById(dropDownName));

    Regards,

    Vipin Jaiswal

    vjcity.blogspot.com/.../dynamic-365-crm-migration-tips-and.html

  • HimalPatel Profile Picture
    80 on at

    Have you got any solution to this issue ? Facing the same issue.

    Thanks,

    Himal

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