Friday, September 23, 2016

Email Signature

In CRM 2016 / Online, you can create email signature, which will be used when sending emails from CRM.

  • Email Signature will be created for Individual user or team
  • User can create more than one email signatures
  • Default signature will be automatically added to email when email created in CRM system.
  • User can select different signature for email, if user has more than one signature.
  • Each user or team has only one default signature.
  • When you change the owner of an email signature, the signature reverts to non-default. For example, a signature is a default for user A. User A assigns it to queue X and queue X already has a default signature. The signature assigned will be non-default for queue X. If queue X does not have a default signature, the new signature will become the default signature.
  • When Form field in email changed, email signature for User / Queue owner will be automatically added to email, if user / queue owner has default signature. 

To create Email signature 
  • Go to user settings and select options 

  • Then select Email Signatures tab

  • Create new Signature

You can set default signature, by clicking on “Set as Default” ribbon button.
If want to remove default signature, for default signature ribbon button will be “Remove Default”.


  • Once Signature is created, now create email
  • By default Form field will be user, and if user has default signature, then signature will be automatically populated in email. 

  •    If there are multiple signature for users and don’t want to use default signature for email, then use “Insert Signature” button shown in Email rich text box ribbon.




Thursday, September 22, 2016

Alternative unique key for an entity

In CRM each entity has unique identifiers defined as GUIDs. This is primary key for each entity. 

Sometimes, when integrating CRM system with other system or converting legacy system into CRM, we need to store existing database unique key into CRM. 

From CRM 2015 Online (update 1) Microsoft introduced alternate keys for entities. 

Alternate keys you can now define an attribute in a CRM entity to correspond to a unique identifier (or unique combination of columns)

Key points for Alternative key
  • Alternate key defined on Decimal number, Whole Number or Single line of Text attributes only.
  • You can combine two or more different types of attributes into Alternate Key.
  • You can create key on maximum 16 columns / attributes combination.
  • Total Key size should not violate SQL based index constraints like 900 bytes per key.
  • For each entity you can define maximum 5 alternate keys. 



Friday, May 13, 2016

Inject your code before CRM button event - Conditional deactivation of CRM record

I came across business requirement like, if there are any active child records, then show error message to users when deactivating parent record.


I can use plugin or real time workflow for this, but when error message thrown, CRM throws error like Business process error.


But customer doesn’t want to see this business process error, customer wants Alert message, and do not want to deactivate record.
To full fill this requirement I customized CRM button command, and added my own script on deactivate button.
Here are steps I did

I am using Ribbon workbench to customize entity ribbon.

1.       Customize Deactivate command

2.       Once command is customized you will see JavaScript library and function used by MS CRM.



3.  Change function Name to NaN and remove parameters for CRM default deactivates action.

This we need to do so when condition is satisfied, record should be deactivated and CRM JavaScript library should be loaded. 


4.       Now add your own JavaScript action in deactivate command, and call your own JavaScript function
When calling own JavaScript function make sure you are using same Parameters used in CRM default deactivates function, as we are going to call this function in our own JavaScript.







5.       In your JavaScript code, you can check, is there any active child records associated with this record? If not then deactivate record, otherwise show message. 

JavaScript code is

CheckOnDeactivation: function (CompanyId, entityName) {
        var req = new XMLHttpRequest();
        req.open("GET", Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc/contact?$select=contactId&$filter=parentcustomerid/Id eq (guid'" + CompanyId + "') and statecode/Value eq 0", false);
        req.setRequestHeader("Accept", "application/json");
        req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
        req.onreadystatechange = function () {
            if (this.readyState === 4) {
                this.onreadystatechange = null;
                if (this.status === 200) {
                    var returned = JSON.parse(this.responseText).d;
                    var results = returned.results;
                    if (results.length >= 1) {
                        alert('You cannot deactivate this record because it has active child records.');                        
                        return false;
                    }
                    else {
                        Mscrm.CommandBarActions.deactivate(CompanyId, entityName);
                        return true;
                    }
                }
                else {
                    alert(this.statusText);
                }
            }
        };
        req.send();
    }

6. Save and Publish customization
Now when trying to deactivate parent if it has any active child then error will be thrown and record will not be deactivated. 

You can use same technique for any other button command.