Tuesday 2 May 2017

MS CRM - Xrm.Page.getAttribute("attribute").fireOnChange() - #JSTip4


Hello All,

In our Xrm clientside object we have an method called fireOnChange(),

Purpose and Usage:
Triggers onchange event of the specific attribute, which in turn triggers the JavaScript functions attached to it.

Scenarios
  • At times, based on business needs we may need to execute a JS logic pinned to field on demand, where this function comes handy.
  • Script updates to a field will not trigger onchange of that field. We can use this way to trigger onchange event of the field if needed. 
Example: 
In account form, we have address fields and on change of address fields there is a logic to populate shipping address. Now when we add a primary contact consider the address fields should be updated from contact address. In this scenario, using JS if we update address fields the shipping address functionality tied to address fields will not fire. This is where we need to use fireOnchange.

Code Snippet:
Xrm.Page.getAttribute("fieldname").fireOnChange()

No comments:

Post a Comment