How to call function other than load or save forms in form properties in CRM 2016 RRS feed

  • Question

  • Hi,

    Please find below jscript on form load function. There is function namely addFilter() which is calling inside function Form_onload()

    I can define the  function Form_onload() in form properties window as shown in below screen.  but how can define addFilter() in form properties window. I can find only Form onload or onsave functions and field change event funtions.  Kindly help me to find solution.

    It was working in CRM 2015 without calling individual functions, even without calling field change event functions in the form properties window.

    function Form_onload()

    clientid = Xrm.Page.context.getUserId();

    usrid = Xrm.Page.context.getUserId();


    function addFilter()


    var customerAccountFilter = “<filter type=’and’><condition attribute=’contactid’ operator=’null’ /></filter>”;
    Xrm.Page.getControl(“customerid”).addCustomFilter(customerAccountFilter, “contact”);


    I am getting below error if I add function inside form load function.  Kindly help me. 


    • Edited by P Noushad Tuesday, April 4, 2017 12:45 PM
    Tuesday, April 4, 2017 11:10 AM

All replies

  • Hi,

    You don't need to register addFilter() function seperately as it's being called inside the Form_onload function.

    The error message talks bout the 'Form_onload' function and nothing about the addFilter function. I would suggest you to remove the web resource from the form completely; save and pubslish. Then add it again to the form and then register the Form_onload function on load of the form and see how it goes.


    Sachith Chandrasiri

    Tuesday, April 4, 2017 11:36 PM
  • Hi,

    I deleted and web resource from the form, the save and published.  I got the same error when I add this functionality.  But other function calling from Form_onload is working.  So this will be some issue in scripts of this function.  Kindly verify scripts. scripts details have been given in first mail.  I want to restrict only accounts when  select potential customer.  This is my requirement.  Now I can select contact and accounts.  I need user should select only account.


    Wednesday, April 5, 2017 11:37 AM
  • Hi,

    so this is a common request on these boards, here's two for you to look at

    this one details why it is not working due to its attribute propertie, customerid

    and this one provides an usupported of doing what you are after

    Saturday, April 8, 2017 5:10 AM