getServerUrl is deprecated in CRM 2015

December 23, 2014 1 comment

Issue: After upgrading to CRM 2015, you will notice that any javascript methods using getServerUrl will stop working. I was in the same boat and after debugging for a while, I found out that this method is not supported anymore in CRM 2015. In order to make this javascript work you will have to use getClientUrl instead.

Resolution: Replace getServerUrl with getClientUrl in all javascript methods/functions.


Limit customer lookup to show only accounts or contacts

July 9, 2014 Leave a comment

Entities like opportunity, case, order and invoice comes out of the box with a customer look that allows users to select between accounts and contacts. It is a very common request from customers to allow users to select only accounts or contacts. In CRM 2011 days, we used to set the defaultlookuptype to 1 for account and 2 for contact but this logic does not work with CRM 2013. With introduction of new client side scripting methods, we can use addPreSearch method to achieve this. In this example, I have called addEventHandler method on load of case form so customer lookup will only show accounts.


function addEventHandler() {



function addFilter() {

var account_filter =”<filter type=’and’>” +

“<condition attribute=’contactid’ operator=’null’ />” +


Xrm.Page.getControl(“parentcustomerid”).addCustomFilter(account_filter, “contact”);


You will see that the filter I used is contactid = null, this is only possible for accounts as contacts will always have their primary key populated.

Server-Based SharePoint Integration – CRM 2013

June 22, 2014 1 comment

Microsoft Dynamics CRM Spring 2014 release has introduced a new approach to CRM and SharePoint integration that is the server-based SharePoint integration. It can be enabled only by using the web or Outlook client for Dynamics CRM. One very important thing with this update is that you cannot revert to the previous client-based authentication method once you enable server-based SharePoint integration.

Steps to enable server-based SharePoint integration in Dynamics CRM Spring ’14 version:

  1. Settings ->Document Management
  2. Click “Enable server-based SharePoint integration”
  3. A wizard will open when you click “Enable server-based SharePoint integration”. Enter your SharePoint Site URL and click “Next”.
  4. Next,the wizard validates your SharePoint site. After validation, click “Next”.
  5. Click “Finish” to finish enabling server-based integraion between Microsoft Dynamics CRM and SharePoint Online.
  6. Now that Server-based SharePoint integration is enabled, you can start using the document management feature in Dynamics CRM as you did with the previous client side integration.


  1. You can view documents in Dynamics CRM without logging into SharePoint.
  2. With this update, you no longer have to install the Dynamics CRM list component in the sandbox environment for Microsoft SharePoint Online.
  3. Once you enable server-based SharePoint integration, you can perform SharePoint actions in the Dynamics CRM command bar.
  4. You can now view SharePoint documents list in native Dynamics CRM grids rather than iFrames.
  5. You can create and save customizable views of document list.


Price list is disabled for all users on opportunity except administrators

January 8, 2014 Leave a comment

Issue: Recently I had this problem dealing with an issue about pricelist being disabled for all security roles except system administrator. I googled a lot and everyone talked about assigning organization level access to pricelist entity in the security roles area but I could not find this entity.

Resolution: After researching a lot, I found out that security role needs to have append and append to access to the product entity.

New JavaScript methods in CRM 2013

January 7, 2014 2 comments

With release of CRM 2013, Microsoft has added some new methods that can be accessed. In the past, we had to write some unsupported JavaScript to get this functionality. More information about all these methods can be found in Microsoft Dynamics CRM 2013 SDK.

• Xrm.Page.context.client.getClient() – Returns client type i.e. outlook, web or mobile.
• Xrm.Page.context.client.getClientState() – Returns client state i.e. online or offline.
• – This is one interesting as it refreshes the data on the form without even reloading the page. This also enables developers to pass a callback method.
• – Save the form
• – Returns true is form is valid for save else false
• – Sets the form dirty for force save.
• – Returns the value of primary attribute
• Xrm.Page.ui.setFormNotification(message,level,uniqueId) – Sets the notification on top of the form.
• Xrm.Page.ui.clearFormNotification() – Clears the form notification
• Xrm.Page.ui.refreshRibbon() – Refreshes the ribbon. This method does not work on CRM for tablets
• Xrm.Page.getControl(“field_name”).setNotification(“Notification”) – Sets the notification for a specific field right next to the field label. This can often be used as a custom tool tip.
• Xrm.Page.getControl(“new_name”).clearNotification() – Clears the notification
• Xrm.Page.getAttribute(“new_precision”).setPrecision(2) – Override field precision
• Xrm.Page.getControl(“createdon”).setShowTime(true) – Toggle show time at form
• Xrm.Page.getControl(“field_name”).addCustomFilter(fetchFilter, entityType) – Allows developer to add custom filter to a lookup view.
• Xrm.Page.getControl(“field_name”).addPreSearch(handler) – adds pre trigger filter to the lookup
• Xrm.Page.getControl(“ownerid”).removePreSearch(handler) – removes the trigger
• Xrm.Utility.openWebResourceDialog(webResourceName, webResourceData, width, height) – opens a sepecified webresource as a web dialog window.

Using the Case Resolution in Workflows via a Custom Workflow Activity

July 1, 2013 Leave a comment

The most common email notification request from customer support team is to “send an email to the client when a case has been resolved” I have written this custom workflow activity to get description field from case resolution dialog and insert in email body.

You can get the complete visual studio solution from this link


  • Download and compile the solution file
  • Register the assembly using plugin registration tool
  • Create a new workflow by selecting case as the primary entity and select record status changes as the trigger
  • add a check condition to verify if the case status = resolved
  • Add a new step and you will find the case resolution option at the very end
  • Add a step for sending email and you can use output from previous step as email body

Workflow Design


Email Body


Creating a knowledge base article using C# plugin

July 1, 2013 2 comments

I am writing this post with complete code to help someone in the community who might be having a similar requirement. Please see the code below:

Entity ent = new Entity(“kbarticle”);
ent.Attributes.Add(“title”, <title>);
ent.Attributes.Add(“kbarticletemplateid”, new EntityReference(“kbarticletemplate”,new Guid(< Template Id >)));
ent.Attributes.Add(“subjectid”, new EntityReference(“subject”, new Guid(<Subject Id >)));

string articlexml = “<articledata><section id=’0′><content><![CDATA[“ + <<This is section 1 descriotion> > + “]]></content></section><section id=’1′><content><![CDATA[“ + <This is section 2 descriotion>  + “]]></content></section><section id=’2′><content><![CDATA[“ + <This is section 3 descriotion> + “]]></content></section></articledata>”;

ent.Attributes.Add(“articlexml”, articlexml);

Important points:

  • Description field is not the body of article. You will have to populate articleXML field
  • ArticleXML depends on the sections defined in your article template. In my case, I had 3 sections in the template.
  • Template ID and Subject ID are required to create articles in CRM