Microsoft Dynamics CRM 2013 Online Server IP Address

Recently we did a POC for one of our client and during this POC we demonstrated the integration between MS CRM 2013 online with well-known billing software. The billing software had a prerequisite to store IP address of the servers from where we are consuming their API to communicate with their system. We found this KP where all the MS CRM 2013 online servers IP address are listed based on the region, where your MS CRM 2013 online organization is hosted for example:

North America



Hope it will help someone!!!

Leave a comment

Filed under MS CRM 2013

Disable Notes section in MS CRM 2013 – Quick Tip

Have you been in a situation where you selected ‘Notes’ while creating entity and after that you realize you don’t need to add notes for that entity at all ?? , if yes you know that there is no supported way removing notes once it is added.

So what are all options we have supported or unsupported? If you only want to go with supported way then you need to delete your entity and recreate it. But you are ready to do unsupported changes you have some options to use your existing entity J .

Recently there was a question in MS CRM Development Forum where user was asking for similar question but that was for MS CRM 2011 (For MS CRM 2011 check this) and Jason Lattimer replied with an option to use JQuery for this, so I thought of trying it and sharing it in this post, so that it can help others MS CRM developers as well, if they are looking for a quick fix.

So if you want to disable notes control, you can create a simple JS web-resource and just add a below function in that, you can call this function in entity form onload.

function DisableNotes()

{                $(“#notescontrol a[title='NOTES']“).attr(‘disabled’, ‘disabled’); }

Note: Make sure to add Jquery library to your entity form.

And if you are interested to hide it completely you can use below line

$(“#notescontrol a[title='NOTES']“).css(‘display’, ‘none’);

Of-course if you are interested, you can implement some more business logic to this for example if you want to disable/hide notes control based on user security role then you can write JS to check current user security and use above to after that.

Note: This is a unsupported customization.

Enjoy !!!

Leave a comment

Filed under MS CRM 2013

SnapShot! for Dynamics CRM


Get your organization details, using SnapShot !!!

Originally posted on Microsoft Dynamics CRM links:

System settings and solution components document generator. Creates an Excel file of the CRM organization with a list of all entities, fields, relationships, views, forms, option sets, web resources, Javascript libraries and events, plugins, processes, security roles and many more components.

View original

Leave a comment

Filed under Uncategorized

Step By Step running On-demand workflow for all active records

Did you get a requirement to run your workflow for all active records ? if yes then this post going to help you to implement the same. OOB in MS CRM web client we can run our on-demand workflow only for 250 records, but there are some workaround to overcome this limitation, for example we could use MS CRM Outlook client, because in outlook client there is no limitation for number of records in per page. If you are using outlook client for MS CRM and interested in this workaround check this.
But if you are not use outlook client for MS CRM then you can use Workflow Execution Manager from MSCRM ToolKit. In this post we are going to provide step by step instruction how to use this tool.
So for implementing this requirement we need to follow three steps

  • Create a on- demand workflow for your requirement.
  • Get FetchXML query for your entity records.
  • Configure Workflow Execution Manager to run your workflow.

Create a on- demand workflow
Let’s create our on-demand workflow, in our example we are creating workflow on Account entity to set custom category as standard. So navigate to Settings->Process ->New and fill below details
Process Name:
Entity: Account
Category: Workflow

Click ok and add update step to set account category as “Standard” (click on Set Properties button to set account record category) . Save and Activate our workflow , after completion our workflow should look like below.
Get FetchXML
Now navigate to Advance find and design your query and click on Download Fetch XML to get fetchxml query
advance find
Configure Workflow Execution Manager
Download MS CRM Toolkit from codeplex and extract it. Click on MSCRMToolKit.exe to start and follow below steps.

  • Select Connection Manager and fill below details


  • Test your connection and close connection manager dialog.

Start Workflow Execution Manger from Tool menu and follow below steps
Profile: Provide any name.
Source: Select your connection name.

Click on (Re) Load Workflow button to load your all on-demand workflows.
Paste your query in Records Query text field and Save your profile from File menu.
It should look like below
Click on Execute workflow, it will start your workflow and will process all resultset based on query provided.

1 Comment

Filed under MS CRM 2011

Sending Email with entity attachment from Notes

If you are looking for sending email with an entity record attachment from Notes then this article is going to help you to implement this requirement. We will explain here how to send email using a workflow with an attachment from Notes regarding an entity. Let’s consider a business scenario where we have implemented a customer approval process and as soon as the customer approves we need to send him notification with an attachment in notes, this attachment contains the details about his account.

We can’t access an attachment from Notes in an OOB workflow so we need to write a custom workflow where we need to get an entity record attachment from an annotation entity and need to create an activitymimeattachment record and need to associate it with the email created. While creating the workflow we need to use a create step instead of sending the email so that we can refer to the email record id.

So mainly we need to use the following procedure to implement our requirements:

  • Develop a custom workflow assembly to get an attachment.
  • Create a workflow and use a custom workflow assembly step to send the email.

Let’s create a custom workflow. If you are new to custom workflow assemblies then please refer to our previous article to create a custom workflow. Create a class library project and add the required assemblies to your project. Let’s rename our class file to SendEmailWithAttachement and use the following code:

namespace EmailAttachment


public class SendEmailWithAttachement : CodeActivity


//define output variable



public InArgument<EntityReference> SourceEmail { get; set; }

protected override void Execute(CodeActivityContext executionContext)


// Get workflow context

IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();

//Create service factory

IOrganizationServiceFactory serviceFactory =          executionContext.GetExtension<IOrganizationServiceFactory>();

// Create Organization service

IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

// Get the target entity from the context

Entity  AccountID= (Entity)service.Retrieve(“account”, context.PrimaryEntityId, new ColumnSet(new string[] { “accountid” }));

AddAttachmentToEmailRecord(service, AccountID.Id, SourceEmail.Get<EntityReference>(executionContext));


private void AddAttachmentToEmailRecord(IOrganizationService service, Guid SourceAccountID, EntityReference SourceEmailID)


//create email object

Entity _ResultEntity = service.Retrieve(“email”, SourceEmailID.Id, new ColumnSet(true));

QueryExpression _QueryNotes = new QueryExpression(“annotation”);

_QueryNotes.ColumnSet = new ColumnSet(new string[] { “subject”, “mimetype”, “filename”, “documentbody” });

_QueryNotes.Criteria = new FilterExpression();

_QueryNotes.Criteria.FilterOperator = LogicalOperator.And;

_QueryNotes.Criteria.AddCondition(new ConditionExpression(“objectid”, ConditionOperator.Equal, SourceTrialRequestID));

EntityCollection _MimeCollection = service.RetrieveMultiple(_QueryNotes);

if (_MimeCollection.Entities.Count > 0)

{  //we need to fetch first attachment

Entity _NotesAttachment = _MimeCollection.Entities.First();

//Create email attachment

Entity _EmailAttachment = new Entity(“activitymimeattachment”);

if (_NotesAttachment.Contains(“subject”))

_EmailAttachment["subject"] = _NotesAttachment.GetAttributeValue<string>(“subject”);

_EmailAttachment["objectid"] = new EntityReference(“email”, _ResultEntity.Id);

_EmailAttachment["objecttypecode"] = “email”;

if (_NotesAttachment.Contains(“filename”))

_EmailAttachment["filename"] = _NotesAttachment.GetAttributeValue<string>(“filename”);

if (_NotesAttachment.Contains(“documentbody”))

_EmailAttachment["body"] = _NotesAttachment.GetAttributeValue<string>(“documentbody”);

if (_NotesAttachment.Contains(“mimetype”))

_EmailAttachment["mimetype"] = _NotesAttachment.GetAttributeValue<string>(“mimetype”);



// Sending email

SendEmailRequest SendEmail = new SendEmailRequest();

SendEmail.EmailId = _ResultEntity.Id;

SendEmail.TrackingToken = “”;

SendEmail.IssueSend = true;

SendEmailResponse res = (SendEmailResponse)service.Execute(SendEmail);




Build and register your assembly using plug-in registration tool. Now we need to create our workflow to use our custom assembly step.

Navigate to Settings->Process to create new process. Select Account in entity drop down and workflow in category.

. Now follow below steps to configure workflow

  •  Add condition to check account approval.
  • Add a step to create email record that we can use in custom step
  • Add our custom workflow steps from Add Step.


Click on Set Properties button to set input variable like below

inputvariableAfter completion it should look like below


Save and Activate workflow.

1 Comment

Filed under MS CRM 2011

Step by Step creating Quick Entity View in MS CRM 2011

During one of our projects we got a requirement to show related entity fields, based on the lookup selection, just like the Quick Entity View feature that we have in Microsoft CRM 2013, so I thought of replicating that for Microsoft CRM 2011. In this article I am sharing code and how to do that so that it can help someone with similar requirements.

Let’s say we want to show contact fields in an account entity form based on the primary lookup selection. To implement this requirement we can use a HTML web resource and use the rest of the endpoints to get contact data based on the contact id selected. So mainly we have the following three steps:

  • Create HTML web resource to get data from child entity and create a html table on the fly.
  • Add HTML web resource in the parent entity form.
  • Create an onchange handler to refresh a HTML web resource when the lookup value is changed.

So let’s create a HTML web resource and name it “/ContactQuickView.html” as in the following.


Click on Text Editor and paste below code:-

<html lang=”en-us”><head>
<title>Contact Quick View</title>
<style type=”text/css”>
font-family: segoe ui;
background-color: #F6F8FA;
td  { width: 130px;
background-color: #F6F8FA;
font-size: 13px;
<script src=”../ClientGlobalContext.js.aspx”></script>
<script type=”text/javascript”>
//check if document is loaded or not
document.onreadystatechange = function () {
if (document.readyState == “complete”) {
parseEntityID();    }  }
function parseEntityID() {
var queryParam = GetGlobalContext().getQueryStringParameters().data;
var fields = queryParam.split(“,”);
var TabName=fields[1];
var SectionName=fields[2];
if (([0])!= null) && ([0]).getValue()!=null))  {
var ContactID =[0]).getValue()[0].id;
//change tab and section name here
RetrieveContactRecord(ContactID);    }
{   window.parent.Xrm.Page.ui.tabs.get(TabName).sections.get(SectionName).setVisible(false);   }  }
//Read contact information
function RetrieveContactRecord(id) {
var ServerURL=window.parent.Xrm.Page.context.getClientUrl();
var ServiceURL=ServerURL+”/xrmservices/2011/organizationdata.svc”;
var req = new XMLHttpRequest();“GET”, ServiceURL + “/Contact” + “Set(guid’” + id + “‘)”, true);
req.setRequestHeader(“Accept”, “application/json”);
req.setRequestHeader(“Content-Type”, “application/json; charset=utf-8″);
req.onreadystatechange = function () {
if (this.readyState == 4 /* complete */) {
if (this.status == 200) {   successCallback(JSON.parse(this.responseText).d);                }
else {  alert(‘Error while reading contact information’);  }  }
req.send();     }
//Added for cross browser support.
function setText(element, text) {
if (typeof element.innerText != “undefined”) {
element.innerText = text;
else {  element.textContent = text;    }  }
//Generate html table to show records
function successCallback(ResultSet)
//store lables
var lbs=new Array();
lbs[0]=”Business Phone”;
lbs[3]=”ZIP/Postal Code”;

//store values
var vals=new Array();
vals[0]=(ResultSet.Telephone1!=null)?ResultSet.Telephone1:” “;
vals[1]=(ResultSet.EMailAddress1!=null)?ResultSet.EMailAddress1:” “;
vals[2]=(ResultSet.Address1_City!=null)?ResultSet.Address1_City:” “;
vals[3]=(ResultSet.Address1_PostalCode!=null)?ResultSet.Address1_PostalCode:” “;
vals[4]=(ResultSet.Address1_StateOrProvince!=null)?ResultSet.Address1_StateOrProvince:” “;
vals[5]=(ResultSet.Address1_Country!=null)?ResultSet.Address1_Country:” “;

//Create a table and header using the DOM
var oTable = document.createElement(“table”);
var oTBody = document.createElement(“tbody”);

for(var i=0; i<6; i++)
var oTRow = document.createElement(“tr”);
var oTRowBlank = document.createElement(“td”);
var oTRowTDBlank1= document.createElement(“td”);
var oTRowTDBlank2= document.createElement(“td”);
var oTRowTD1 = document.createElement(“td”);’003DB2′;
setText(oTRowTD1, lbs[i]);
var oTRowTD2 = document.createElement(“td”);
setText(oTRowTD2, vals[j]);

var oTRowTD3 = document.createElement(“td”);’003DB2′;
setText(oTRowTD3, lbs[i+1]);
var oTRowTD4 = document.createElement(“td”);
setText(oTRowTD4, vals[j+1]);
document.body.appendChild(oTable);   }
<meta charset=”utf-8″></head><body>

Note: Please make sure to change quotations sign if you are copying code.

Now we have html web resource ready, place it under the parent entity form, while placing web resource we need to pass three parameters:

  • Name of the lookup field for child entity.
  • Name of the tab and section where we have placed web resource like below


Now we need to create a JS webresource and need to use below code. We have to call this function on primary contact  lookup field onchange on account entity form to refresh web resource once value will be changed.
function reloadTerrtoryQuickView()

{ var wrControl = Xrm.Page.ui.controls.get(“WebResource_TerritoryQuickView”);

wrControl.setSrc(wrControl.getSrc()); }

And once we will open account form it will show related information based on the primary contact selected like below

contactviewImageEnjoy !!!

Leave a comment

Filed under MS CRM 2011, Step By Step MS CRM 2011

South East Asia MVPs Community Day 2013

1450171_10152583963980288_445345355_nSouth East Asia MVP Community is celebrating MVP Community Day on this Saturday, where MVPs from Asia community doing different events like Webcasts and On-line Chat related to their respective technology.

I am doing online chat and a webcast on “What is new in MS CRM 2013″ with my fellow MVP Roohi Shaikh.

You can register here for this event:

Check here for other community day activities.

See you at the event.



Leave a comment

Filed under New Feature in MS CRM 2013