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)

there was an error with the field's customized event onload

(0) ShareShare
ReportReport
Posted on by

Hi ,

I have the following error when loading the form of one of my custom entities :"there was an error with the field's customized event crm onload"  with the name of a specific function i 'am calling , I verifiied the js file (formating ,brackets ,..) all ok .

Also i'am using the same js file in another entity & i get the same error when loading the form but with different function .

Any suggestions?

Kind Regards

*This post is locked for comments

I have the same question (0)
  • ashlega Profile Picture
    34,477 on at

    Hi David,

     you'd probably need to post that script here.

     And, also, maybe you could post a screenshot of how you've set up the event handler..

  • Community Member Profile Picture
    on at

    Hi Alex ,

    The problem is that the entity is very customized and I have more than 1400 line of code.

    for the event handler I 've added the functions to the "onload event".

    Thank you

  • Community Member Profile Picture
    on at

    here is the first function i'am calling :

    function function1() {

       var Status = Xrm.Page.data.entity.attributes.get("statuscode").getValue();

       if (Status == 100000000) {

           function2();

       }

    }

    function function2() {

       var controls = Xrm.Page.ui.controls.get();

       for (var i in controls) {

           var control = controls[i];

           if (!control.getDisabled()) {

               control.setDisabled(true);

           }

       }

    }

  • Verified answer
    ashlega Profile Picture
    34,477 on at

    Hi David,

     maybe it's because not every control has "getDisabled"/"setDisabled":

    try this:

    function function2() {

      var controls = Xrm.Page.ui.controls.get();

      for (var i in controls) {

          var control = controls[i];

          if (typeof(control.getDisabled) != 'undefined' && !control.getDisabled()) {

              control.setDisabled(true);

          }

      }

    }

  • Verified answer
    Community Member Profile Picture
    on at

    This is the function you need:

    function SafeDisableAllControls()
    {
        Xrm.Page.ui.controls.forEach(function (control, index)
        {
            var controlType = control.getControlType();
            if (controlType != "iframe" && controlType != "webresource" && controlType != "subgrid")
            {
                if (!control.getDisabled()) {
                    control.setDisabled(true);
                }
            } 
        });
    }

    If you found the answer helpful, please mark as Verified 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna, ITALY

    Independent Contractor

    http://www.francescopicchi.com

  • ashlega Profile Picture
    34,477 on at

    Well.. how about timer control?

    typeof(control.getDisabled) != 'undefined'

    will work correctly for past, current, and future controls.

  • Community Member Profile Picture
    on at

    Hello Alex and Francesco ,

    Thank you a lot for your responses . i just find out what ,was the probleme.

    The probleme is from another function in my js file .

    Thank yousu much .

    Best regards ,

    David

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