locked
CRM 2015 Javascript error- 'There was an error with this field's customized event.' RRS feed

  • Question

  • Hello,

    I am trying to hide some fields in Opportunity-Sales Business Process Flow using javascript. The javascript snippet is :-

    function hidectlr()
    {
        alert('a'); 
        if(Xrm.Page.getControl("header_process_new_opportunityhierarchyid" != null)
                {
                     alert('b');  
                     Xrm.Page.getControl("header_process_new_opportunityhierarchyid").setDisabled(true);
                 }
    }

    I am calling the funtion in Onload event. When I open an opportunity I get the following error:-

    'There was an error with this field's customized event.'

    Field:window

    Event:onload

    Error:'hidectlr' is undefined.

    Thanks!

    Thursday, February 12, 2015 11:47 AM

All replies

  • You missed a bracket in If condition

    {
        alert('a'); 
        if(Xrm.Page.getControl("header_process_new_opportunityhierarchyid") != null)
                {
                     alert('b');  
                     Xrm.Page.getControl("header_process_new_opportunityhierarchyid").setDisabled(true);
                 }
    }


    Regards, Saad

    Thursday, February 12, 2015 11:57 AM
  • Hello Saad,

    Thank you for your reply!!

    It got me running till alert('b');

    but now I get a new error:- Unable to get property 'setDisabled' of undefined or null reference.

    Thanks!

    Thursday, February 12, 2015 12:06 PM
  • Please check if the field name in Business Process Flow Header "header_process_new_opportunityhierarchyid" is correct and valid.

    Put an alert alert(Xrm.Page.getControl("header_process_new_opportunityhierarchyid")) 

    Refer this.


    Regards, Saad



    • Edited by Mohd Saad Thursday, February 12, 2015 12:30 PM
    Thursday, February 12, 2015 12:29 PM