Category Archives: CRM 2013 Client API

How to Hide a Ribbon Button

Working on Contact customizations i encounter that the customer do not want to allow the users to click the button New, and only the System Administrators have the capability to Create new records.

They business need was that the integration application will bring the new records from an external application and the users will be able to read and append information, but not to create, I also created a Security Role for that, but researching i found that also can be done in client side.

 

// Hide a Ribbon Button
var btnNewRecord = top.document.getElementById("incident|NoRelationship|Form|Mscrm.Form.incident.NewRecord");
btnNewRecord.style.display = 'none';

 

The 3rd option was to create a copy of the form an only allow the System Administrators to have access to the New button.

So there are many different ways for a solution, it depends what is the best for your business request.

 

 

Abe

CRMBuzz

How to replace Lookup empty Name, with different field value

I just started working with a new customer and we already have some interesting challenges, some of the bulk import data, have most of the Contact Entity records empty except with on field that was an representation from other system called the Customer Number.

Well when CRM displays the Contact information is really nothing, just have the 5000+ records count and nothing on the screen, well I fixed that adding the Customer Number to the Views, but then another issue, in a relation with other entity the Contact relays in the Full name to display as part of the Lookup field, but there is no Full name on the record and can’t be clicked to take you back to the Contact record.

The solution is to have client side code that will run on the Onload event of the form, get the current Lookup information, make a request to get the Contact record information using oData, and reassign the Lookup Name value with other field on the Contact Entity.

The following is the code used to accomplish the solution on the related entity. You need to add the function “changeCustomerLookup()” to the form onload event.
Also you will need the following Files to be included in your form libraries:

  •  abe_jason2.js
Download
  • abe_SDK.REST.js
Download
  • abe_SDK.JQuery.js
Download

 


function changeCustomerLookUp() {

var ExistingContact = Xrm.Page.data.entity.attributes.get("abe_contact");
    if (ExistingContact.getValue() != null) {
        var ExistingGUID = ExistingContact.getValue()[0].id;
        var _ToEntity = "Contact";
        SDK.REST.retrieveRecord(ExistingGUID, _ToEntity, "*", null,
        function (result) {
            if (result.LastName == null) {

                var ExistingName = result.abe_customernumber;


     SetLookupValue("abe_contact", ExistingGUID, ExistingName, "contact");

            }

        }, function (error) { alert('Contact Error:' + error.message) });


    }
}

function SetLookupValue(fieldName, id, name, entityType) {
    if (fieldName != null) {
        var lookupValue = new Array();
        lookupValue[0] = new Object();
        lookupValue[0].id = id;
        lookupValue[0].name = name;
        lookupValue[0].entityType = entityType;
        Xrm.Page.getAttribute(fieldName).setValue(lookupValue);
    }
}

Downlod the Client side code here: abe_LookupEdit.js Download

enjoy the code, please leave your comments and recomendations

 

Abe Saldana

CRMBuzz.

Why to use CRM Diagnostics Page!

Network performance between the client and server will play a key factor in how well CRM performs for the end users. It is very common to have users working from remote locations where the network performance is unknown. There are several methods to test network performance, but since the release of Update Rollup 4 CRM has included its own diagnostics page to show bandwidth, latency and JavaScript Rendering performance.

This diagnostics page will issue a series of pings from client to server and transfer several blobs of data. Based on this data it will provide the latency in milliseconds and max transfer speeds achieved. This is a quick and easy way to identify the network performance without having to install any tools on the client or server. Using this tool you can gather baseline performance from various locations and determine expected response times given the users bandwidth and latency.  This should be taken into consideration when planning and designing a CRM environment to provide the best user experience available.

To use the diagnostics page you can simply browse to the page by using the URL http://<YourCRMServerURL>/tools/diagnostics/diag.aspx and click the Run button to start the tests. This page is available for both CRM Online and On-Premise.

Other Reference:

Optimizing and Maintaining client Performance for MS Dynamics CRM 2011 and CRM Online

Image CRM 2011 Diagnostics Page

CRM 2011 Diagnostics Page
CRM 2011 Diagnostics Page