How To – Series 5: How To Use “ValueRule” and “OrRule” in Ribbon Customizations – CRM 2011
Now, In this post I would like to add few more things on how to use “ValueRule” and “OrRule” rules with “EnableRules”.
<ValueRule Field=”fax” Value=”null” InvertResult=”true”/>
</EnableRule>
<EnableRule Id=”Sample.account.form.CheckFaxValue.EnableRule”/>
And when “Fax” field has a value:
That’s cool. With single line additional code we can enable/disable custom button based on field value.
<EnableRule Id=”Sample.account.form.CheckContactValue.EnableRule”>
<ValueRule Field=”address1_addresstypecode” Value=”1″/>
</EnableRule>
<EnableRule Id=”Sample.account.form.CheckFaxValue.EnableRule”>
<ValueRule Field=”fax” Value=”null” InvertResult=”true”/>
</EnableRule>
And
<EnableRule Id=”Sample.account.form.CheckFaxValue.EnableRule”/>
<EnableRule Id=”Sample.account.form.CheckContactValue.EnableRule”/>
Below is the result:
<EnableRule Id=”Sample.account.form.OrRule.EnableRule”>
<OrRule>
<Or>
<ValueRule Field=”fax” Value=”null” InvertResult=”true”/>
</Or>
<Or>
<ValueRule Field=”address1_addresstypecode” Value=”1″/>
</Or>
</OrRule>
</EnableRule>
And refer the “Id” at the following: //CommandDefinitions/CommandDefinition/EnableRules
<EnableRule Id=”Sample.account.form.OrRule.EnableRule”/>
Below is the result with “OrRule”:
This post gives basic idea on how to use “ValueRule” and “OrRule” in Ribbon Customizations. Hope it helps…!!! J
Silverlight Fire Starter Live Cast
Watch Silverlight Fire Starter 2010 here….
How To – Series 4: How to make an Associated View IFrame Mandatory
{
if (crmForm.all.IFRAME_ MyIFrame.readyState == “complete”)
{
if (document.frames(“IFRAME_ MyIFrame”).document.all[‘crmGrid’].InnerGrid.NumberOfRecords < 1)
{
event.returnValue=false;
alert(“Please Select Records”);
var oaddexist=document.frames(‘IFRAME_ MyIFrame’).document.getElementById(‘<id of the add existing button>’);
if(oaddexist)
{
oaddexist.focus();
}
}
}
}
}
{
ValidateIFrame();
}
Hope it helps…
Thanks
Vikranth P.
How To – Series 3: How to bulk Activate/Reactivate Dynamics CRM Records using CRM Update Web Service in Java Script
1. Creating an ISV button on the “Lead” entity’s crmGrid
<Entity name=”lead”>
<ToolBar ValidForCreate=”0″ ValidForUpdate=”1″>
<Button Icon=”/_imgs/ico_18_debug.gif” JavaScript=”alert(“Your JavaScript code will be here”)”>
<Titles>
<Title LCID=”1033″ Text=”Reactivate” />
</Titles>
<ToolTips>
<ToolTip LCID=”1033″ Text=”Reactivate” />
</ToolTips>
</Button>
</ToolBar>
</Entity> />
Hope it helps you…
Vikranth P
How To – Series 2: How to make Phone Number field as CTI integrable or make IFrame look alike Label on Crm Form
How To – Series 1: How to add/change filter criteria of a Lookup field in Java Script
Hi all… This is my first blog post in How-To Series.
Let’s consider a scenario, where we have three picklist fields on a form and the Lookup filed search criteria is depended on selected picklist values. For an instance, if we have Account Type, Product Type and Call Type as picklists and the requirement is like by the time user clicks on the Lookup filed it should have below as the filter criteria
1. Include only the picklists whose value is selected
2. If none of the picklist is selected then display all active records
Below is the code which needs to be placed in the onLoad of the crmForm. As the fetchxml code needs to be changed as per the user picklist selection, I have declared four variables named param, headparam, tailparam and bodyparam. In which bodyparam content is changing as per the user selection. Finally I am concatenating headparam, bodyparam and tailparam to generate required fetchxml code. I am implementing entire code as a function so that it can be called from the picklist’s onchange events instead copy and pasting entire code each and every place.
crmForm.lookupquery = function xyz() {
var field = crmForm.all.abaxis_lookupid;
field.lookupbrowse = 1;
var headparam = “<fetch mapping=’logical’><entity name=’new_myentity’><all-attributes /><filter type=’and’>”;
var tailparam = “</filter></entity></fetch>”;
var bodyparam = “”;
var param = “”;
if (crmForm.all.new_plproducttype.DataValue != null)
bodyparam = bodyparam + “<condition attribute=’new_producttype’ operator=’eq’ value='” + crmForm.all.new_plproducttype.DataValue[0].id + ” ‘/>”;
if (crmForm.all.new_placcounttype.DataValue != null)
bodyparam = bodyparam + “<condition attribute=’new_accounttype’ operator=’eq’ value='” + crmForm.all.new_placcounttype.DataValue + ” ‘/>”;
if (crmForm.all.new_plcallfor.DataValue != null)
bodyparam = bodyparam + “<condition attribute=’new_callfor’ operator=’eq’ value='” + crmForm.all.new_plcallfor.DataValue + ” ‘/>”;
if (bodyparam == “”)
bodyparam = “<condition attribute=’statecode’ operator=’eq’ value=’0’/>”;
param = headparam + bodyparam + tailparam;
field.AddParam(“search”, param);
}
crmForm.lookupquery();
onChange:
Add crmForm.lookupquery(); to all the picklist attributes onChange() event so that as soon as a picklist value is changed lookup field filter criteria will also be changed.
Hope it helps you..!!!!
Cheers
VikranthP