Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

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

Posted on by Microsoft Employee

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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: there was an error with the field's customized event onload

    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

  • ashlega Profile Picture
    ashlega 34,475 on at
    RE: there was an error with the field's customized event onload

    Well.. how about timer control?

    typeof(control.getDisabled) != 'undefined'

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

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: there was an error with the field's customized event onload

    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

  • Verified answer
    ashlega Profile Picture
    ashlega 34,475 on at
    RE: there was an error with the field's customized event onload

    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);

          }

      }

    }

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: there was an error with the field's customized event onload

    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);

           }

       }

    }

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: there was an error with the field's customized event onload

    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

  • ashlega Profile Picture
    ashlega 34,475 on at
    RE: there was an error with the field's customized event onload

    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..

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans