In this recipe we will drill down to a lower level. We have handled form events, and now it is time to handle field events. The following recipe will show you how to bring all these together and achieve exactly the result you need.
For the purpose of this recipe, let's focus on reusing the previous solution. We will check the value of a field, and act upon it.
In order to walkthrough this recipe, follow these steps:
function ChangeEvent() { var _changeEventSelection = null; var _isChanged = Xrm.Page.getAttribute("new_changeevent"); if(_isChanged != null) { _changeEventSelection = _isChanged.getValue(); } if(_changeEventSelection == true) { alert("Change event is set to True"); // perform other actions here } else { alert("Change event is set to False"); } }
Handling events at the field level, specifically the OnSave
event, allows us to dynamically execute various other functions. We can easily take advantage of this functionality to modify the form displayed to a user dynamically, based on a selection. Based on a field value, we can define areas or field on the form to be hidden and shown.
3.133.144.18