Friday, April 8, 2016

How to restore Button's in MSCRM

Hi All,

Please find the below steps to restore all the Entity Ribbon in Custom or OOB entity


    1. Create a solution that just includes the entity with the button that isn’t working correctly and export from CRM.
    2.Extract the customization zip file.
    3.Open the customization.xml file in the editor of your choice.
    4.Search for RibbonDiff.
    5.Replace the entire <RibbonDiff> section with the following:

<RibbonDiffXml>
  <CustomActions />
  <Templates>
    <RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
  </Templates>
  <CommandDefinitions />
  <RuleDefinitions>
    <TabDisplayRules />
    <DisplayRules />
    <EnableRules />
  </RuleDefinitions>
  <LocLabels />
</RibbonDiffXml>

      6.Then Save it.
      7.Compress the Folder and import it to the Organization.
      8.Publish all Customization.

Friday, April 1, 2016

Hide Subgrid + Button For Attachment in Email Entity Etc

Hi all,

I have got a requirement to hide + new button for Attachment in Sub-Grid. Please find the code to achieve the same

Javascript:

        setTimeout(function () {
            if (Xrm.Page != null && Xrm.Page != undefined && Xrm.Page.getControl("attachmentsGrid") != null && Xrm.Page.getControl("attachmentsGrid") != undefined) {
                document.getElementById("attachmentsGrid_contextualButtonsContainer").style.display = "none";
            }
        }, 500);

We can use the above code to hide all the Subgrid + Button. You need to replace "attachmentsGrid" as your Subgrid name to achieve the same.

Wednesday, March 30, 2016

Two Default Views for an entity in MS CRM 2011

HI All,

Please find the below Solution to fix the two default view for an entity.

1. Create a solution by taking your Entity only.
2. Export the solution and unzip it
3. open the Customization.xml file in VS studio
4. then search for the View in saved queries node tag
5. change <isdefault> value from 1 to 0.
6. then zip the solution and import it, publish it and check. there will be one default public view

Monday, March 28, 2016

Validate date MSCRM Javascript

function ValidateDates() {
    var Date1 = Xrm.Page.getAttribute("scheduledstart").getValue();
    var Date2 = Xrm.Page.getAttribute("scheduledend").getValue();
    if (Date1 != null && Date2 != null) {
        if (Date1.setHours(0, 0, 0, 0) < Date2.setHours(0, 0, 0, 0)) {
            alert("You must specify an end time that happens after the start time");
        }
    }
}

Wednesday, March 16, 2016

Get All Plugin Registation Steps (SQL) MSCRM

Hi All,

Please find the below SQL script to get all the plugin registration steps

SELECT T.PluginAssemblyIdName AS PluginName, S.name AS StepName,
S.description AS StepDescription, M.name AS Action, E.name AS Entity,
CASE S.Stage WHEN 20 THEN 'PRE' WHEN 40 THEN 'POST' ELSE 'OTHER' END AS Stage,
CASE S.StateCode WHEN 0 THEN 'Enabled' WHEN 1 THEN 'Disabled' ELSE 'Other' END AS State
FROM SdkMessageProcessingStepBase S -- Steps Table
JOIN SdkMessage M ON(S.SdkMessageId = M.SdkMessageId)
JOIN SdkMessageFilter F ON(S.SdkMessageFilterId = F.SdkMessageFilterId)
JOIN EntityAsIfPublishedLogicalView E ON(E.ObjectTypeCode = F.PrimaryObjectTypeCode)
JOIN PluginType T ON(T.PluginTypeId = S.PluginTypeId)



Tuesday, March 15, 2016

Get Business Unit Id For the User CRM Javascript

Hi All,

JavaScript  to get Business Unit ID For the User

var businessUnitId = GetBusinessUnitIDFortheUser (loggedInUser);

function GetBusinessUnitIDFortheUser(userId) {
    try {
        if (serverUrl == null) {
            serverUrl = GetCRMServerUrl();
        }

        var oDataEndpointUrl = Xrm.Page.context.getServerUrl() + "/XRMServices/2011/OrganizationData.svc/";
        oDataEndpointUrl += "SystemUserSet?$select=BusinessUnitId&$filter=SystemUserId eq guid'" + userId + "'";
        var service = GetRequestObject();

        if (service != null) {
            service.open("GET", oDataEndpointUrl, false);
            service.setRequestHeader("X-Requested-Width", "XMLHttpRequest");
            service.setRequestHeader("Accept", "application/json,text/javascript, */*");
            service.send(null);

            var requestResults = eval('(' + service.responseText + ')').d;
            if (requestResults != null && requestResults.results.length == 1) {
                var userRecord = requestResults.results[0];
                if (userRecord.BusinessUnitId && userRecord.BusinessUnitId.Id) {
                    return userRecord.BusinessUnitId.Id;
                }
            }
        }

        return "";
    }
    catch (err) {
        return "";
    }
}


Get View ID Based on View Name MSCRM 2013 & CRM 2015

Hi All,

Get View ID Based on Name


GetViewIdByName("ViewName");

function GetViewIdByName(viewName) {
    var viewId = "";
    var fetchXml =
       "<fetch mapping='logical'>" +
          "<entity name='savedquery'>" +
          "<attribute name='savedqueryid' />" +
          "<filter>" +
          "<condition attribute='name' operator='eq' value='" + viewName + "' />" +
          "</filter>" +
          "</entity>" +
       "</fetch>";

    var retrievedViews = XrmServiceToolkit.Soap.Fetch(fetchXml);
    viewId = retrievedViews[0].attributes['savedqueryid'].value;
    return viewId;
}

Day 11 - Customizing Option Sets Dropdown Fields with JavaScript

  In this Blog, we will see how to Customizing Option Sets Dropdown Fields with JavaScript label1 = formContext.getAttribute( "bosch_op...