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)

JS on OnLoad form error

(0) ShareShare
ReportReport
Posted on by

Hello,

I wrote a very easy JS that works on OnLoad of the Form, but I have an "TypeError: Cannot read property 'Initialize' of undefined at eval (eval at RunHandlerInternal" error.

If anyone of you might help, it would be amazing!

Script si below. 

// JavaScript Document

function showHide(){

var queryType = Xrm.Page.getAttribute("srm_reviewtype").getValue();
if(queryType != null){

if(queryType == 165780000){
Xrm.Page.ui.tabs.get("GeneralTab").sections.get("REVIEW_INFORMATION").setVisible(true);
Xrm.Page.ui.tabs.get("GeneralTab").sections.get("FINANCIAL_STATUS_CHECK").setVisible(true);
Xrm.Page.ui.tabs.get("GeneralTab").sections.get("PERFORMANCE_REVIEW").setVisible(false);
Xrm.Page.ui.tabs.get("GeneralTab").sections.get("FEEDBACK_BY").setVisible(false);
Xrm.Page.ui.tabs.get("GeneralTab").sections.get("ACTIVITIES").setVisible(false);
}

else if(queryType == 165780001){
Xrm.Page.ui.tabs.get("GeneralTab").sections.get("REVIEW_INFORMATION").setVisible(true);
Xrm.Page.ui.tabs.get("GeneralTab").sections.get("FINANCIAL_STATUS_CHECK").setVisible(false);
Xrm.Page.ui.tabs.get("GeneralTab").sections.get("PERFORMANCE_REVIEW").setVisible(true);
Xrm.Page.ui.tabs.get("GeneralTab").sections.get("FEEDBACK_BY").setVisible(true);
Xrm.Page.ui.tabs.get("GeneralTab").sections.get("ACTIVITIES").setVisible(true);
}
}

else
{
Xrm.Page.ui.tabs.get("GeneralTab").setVisible(true);
}
}

*This post is locked for comments

I have the same question (0)
  • Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Hi Dominik,

    I don't think that error has anything to do with your onLoad code. Your code looks fine.

    You can put a breakpoint in your code and see if it reaches your code, or it might be a CRM error.

    Can you try running your site in InPrivate mode and see if you get the same error?

    It is possibly some caching issue or null value issue.

    I am attaching a function that you can use to show/hide sections in your code. Makes it simpler to write some of the code and prevent issues:

    // Set Section Visibility

    setSectionVisibleState("GeneralTab", "REVIEW_INFORMATION", true);

    function setSectionVisibleState(tabName, sectionName, isVisible)

    {

       Xrm.Page.ui.tabs.get(tabName).sections.get(sectionName).setVisible(isVisible);

    }

  • ashlega Profile Picture
    34,477 on at

    Hi Dominik,

     is it all the code you have in that web resource? I don't see any errors either.. besides, the error looks s a bit unusual to say the least.

  • VermaNitin Profile Picture
    455 on at

    Hi Dominik,

    At the first sight it seems that the issue does not belong to your code.

    Try clearing the cache or try using another browser.

    Is the error shown in an alert on the form? If not then you can just neglect it or at the last you may contact Microsoft support.

    Hope it helps!

    Many thanks,

    Nitin Verma

  • Community Member Profile Picture
    on at

    Hi Dominik,

    I don't have enough details to know if you can use it, but you can assess to create "Business Rules" in your form to Show/hide fields instead of JS.

    A small "trick" is that, if you have a section "not visible" by default, and then you have a Business rules to show a field in the section, that section will appear, not only the field.

    Hope this helps.

  • abhishek_255 Profile Picture
    1,614 on at

    You can try commenting the function body and put an alert just to validate any issue while function call. In case alert appears then there must be something wrong in your function body. You can use developer tools and debug your java script at runtime.

    Otherwise validate the container (web resource) and function name.

    Best Regards,

    Abhishek

  • Community Member Profile Picture
    on at

    I saw this once before and removing the javascript from the form and adding it back, oddly enough, seemed to resolve it.

  • Community Member Profile Picture
    on at

    Hello

    community.dynamics.com/.../194344

    Hope this link may help you!

  • Verified answer
    Community Member Profile Picture
    on at

    After all I didn't find a solution. I had to create a new custom entity and then it worked well.

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