Sunday, December 14, 2014


Different Types of Events Supported by Jscript in MS-CRM



1) OnLoad : This is a form event. Executes when a form is loaded.
Most common use is to filter and hide elements on the
form.

2) OnSave : This is a form event. It executes when a form is saved.
Most common use is to stop an operation from
executing, as a result of a failed validation procedure.

3) TabStateChange : This is a form event. It executes when the
DisplayState of the tab changes.

4) OnChange : This is a field specific event. It executes
when tabbing out of a field where you've changed
the value. Please note that there is no equivalent
for onfocus and onblur.

5) OnReadyStateComplete : This event indicates that the content
of an IFrame has completed loading.


2) Preventing the Default behaviour of MS-CRM form


function StopSave(context)
{
var _isSpecialSelection = null;
var _isSpecial = Xrm.Page.getAttribute("new_isspecialcustomer");
if(_isSpecial != null)
{
_isSpecialSelection = _isSpecial.getValue();
}
if(_isSpecialSelection == false)
{
alert("You cannot save your record while the Customer is not a
friend!");
context.getEventArgs().preventDefault();
}
}

3) Show and Hide a Tab

function ShowTab()
{
Xrm.Page.ui.tabs.get("notes and activities").setVisible(true);
}

function HideTab()
{
Xrm.Page.ui.tabs.get("notes and activities").setVisible(false);
}


4) Hide and Show a Section

function HideSection()
{
Xrm.Page.ui.tabs.get("notes and activities").sections.
get("activities").setVisible(false);
}

function ShowTab()
{
Xrm.Page.ui.tabs.get("notes and activities").setVisible(true);
}




No comments:

Post a Comment