serving the solutions day and night


Friday, August 30, 2013

MS Dynamics CRM 2011 - EnableRule, ValueRule, OrRule & CustomRule in Ribbon Customizations

ValueRule - Enable the Custom button only when a specific filed on the form has a value.
For example, if the 'Email' field has value then the custom will be enable otherwise it will disable.


<EnableRule Id="">
    <ValueRule Field="email" Value="null" InvertResult="true"/>

EnableRule for mulitple fields, use 'OrRule', for example

<EnableRule Id="">
            <ValueRule Field="email" Value="null" InvertResult="true"/>
              <ValueRule Field="leadsourcecode" Value="810520005"/>
EnableRule only works with Equal(=) condition, for different conditions (not equal) use 'InvertResult' attribute.

Refer the above id in the following location /RibbonDiffXml/CommandDefinitions/CommandDefinition/EnableRules

<EnableRule Id="Sample.account.form.CheckFaxValue.EnableRule"/>

CustomRule - call a javascript function based on the result.

<EnableRule Id="">
  <CustomRule FunctionName="DisableReportButton" Library="$webresource:dns_JavaScript/reports.js" Default="true" />

Thursday, August 29, 2013

Show Pipeline Custom Component in Visual Studio ToolBox

Show Pipeline Custom Component in Visual Studio ToolBox

Add the below code in the Project Build Events

"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\GacUtil.exe" /i "$(TargetPath)" /f
xcopy "$(TargetPath)" "C:\Program Files (x86)\Microsoft BizTalk Server 2010\Pipeline Components" /d /y

MS Dynamics CRM 2011 - Paging Retrieve Multiple Records

QueryExpression query = new QueryExpression(Contact.EntityLogicalName);
EntityCollection coll;
query.PageInfo.PageNumber = 1;
query.ColumnSet = new ColumnSet("firstname", "lastname");
    int RecordId = 1;
    coll = CRMServiceProxy.RetrieveMultiple(query);
    foreach (Entity e in coll.Entities)
        Console.WriteLine(query.PageInfo.PageNumber + " - " + RecordId + " - " + e.Attributes["firstname"] + " - " + e.Attributes["lastname"]);
while (coll.MoreRecords);

public static OrganizationServiceProxy CRMServiceProxy
                var uri = new Uri(System.Configuration.ConfigurationManager.AppSettings["CrmOrganizationUri"]);

                //Authenticate using credentials of the logged in user;      
                var cnt = new ClientCredentials();
                cnt.Windows.ClientCredential.Domain = System.Configuration.ConfigurationManager.AppSettings["CrmDomain"].ToString();
                cnt.Windows.ClientCredential.UserName = System.Configuration.ConfigurationManager.AppSettings["CrmUserName"].ToString();
                cnt.Windows.ClientCredential.Password = System.Configuration.ConfigurationManager.AppSettings["CrmPassword"].ToString();
                //cnts.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;

                var sp = new OrganizationServiceProxy(uri, null, cnt, null);

                return sp;

Avoid Empty Nodes Using Table Looping Functoid in BizTalk

Avoid Empty Nodes Using Table Looping Functoid in BizTalk

You will find out lot of several posts to avoid empty nodes using Table Looping Functoid
My Flat Source File looks like this


Flat file converted to the XML (StudentIn.xml) using pipeline components


Monday, August 12, 2013

MS Dynamics CRM - Security Role

I have one situation, login user has multiple security roles, if the login user has permission for particular role, show some buttons/fields otherwise the hide buttons/fields.

It is not stright forward to find out the security role, So i wrote one javascript to find out the security role.

<script src="../ClientGlobalContext.js.aspx" type="text/javascript"></script>
<script src="/WebResources/gab_JavaScript/Jquery1.10.2.min.js" type="text/javascript" language="javascript"></script>
<script src="/WebResources/gab_JavaScript/Jason.js" type="text/javascript" language="javascript"></script>

function context() {
    if (typeof GetGlobalContext != "undefined") {
        return GetGlobalContext();
    else {
        if (typeof Xrm != "undefined") {
            return Xrm.Page.context;

function GetServerUrl() {
    var Crmurl = window.location;
    var orgName = context().getOrgUniqueName();
    return Crmurl.protocol + "//" + + "//" + orgName + "/xrmservices/2011/OrganizationData.svc/";

Here i am checking the user has "Content Manager" security role or not.

function BookAuditMatch() {
   var ECMRole = CheckUserRole("Book Content Manager");
   if (ECMRole) {
      //Do something

This function will get all the user's security role Id, passing security role id to get the security role name. If it match, it is true otherwise false.
function CheckUserRole(roleName) {
    var currentUserRoles = Xrm.Page.context.getUserRoles();
    for (var i = 0; i < currentUserRoles.length; i++) {
        var userRoleId = currentUserRoles[i];
        var userRoleName = GetRoleName(userRoleId);
        if (userRoleName == roleName) {
            return true;
    return false;

This function calling odata web service and get the each security role name.
function GetRoleName(userRoleId) {
    var selectQuery = "RoleSet?$top=1&$filter=RoleId eq guid'" + userRoleId + "'&$select=Name";
    var VoterAddress = "";
    var odataSelect = GetServerUrl() + selectQuery;
    var roleName = null;
        type: "GET",
        async: false,
        contentType: "application/json; charset=utf-8",
        datatype: "json",
        url: odataSelect,
        beforeSend: function (XMLHttpRequest) { XMLHttpRequest.setRequestHeader("Accept", "application/json"); },
        success: function (data, textStatus, XmlHttpRequest) {
            var result = data.d;
            if (!!result) {
                roleName = result.results[0].Name;
        error: function (XmlHttpRequest, textStatus, errorThrown) {
            //alert('OData Select Failed: ' + odataSelect);
    return roleName;

File Lock Error In Visual Studio

Your project dll is referenced by another project, when you trying to build a project, you will get file lock issue in visual studio,

Unable to copy file "obj\Debug\BizTalk.MSDynamicsCRM2011.Schemas.dll" to "bin\BizTalk.MSDynamicsCRM2011.Schemas.dll". The process cannot access the file 'bin\BizTalk.MSDynamicsCRM2011.Schemas.dll' because it is being used by another process.

if exist "$(TargetPath).locked" del "$(TargetPath).locked"
if exist "$(TargetPath)" if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"

if exist "$(ProjectDir)bin\$(TargetFileName).locked" del "$(ProjectDir)bin\$(TargetFileName).locked"
if exist "$(ProjectDir)bin\$(TargetFileName)" if not exist "$(ProjectDir)bin\$(TargetFileName).locked" move "$(ProjectDir)bin\$(TargetFileName)" "$(ProjectDir)bin\$(TargetFileName).locked"

Register dll in 'C:\Windows\Microsoft.NET\assembly\GAC_MSIL'
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\GacUtil.exe" /i "$(TargetPath)" /f