Unable to Login to Dynamics CRMOrganizationServiceProxy is null error while using CrmServiceClient

While connecting to Dynamics 365 – Version online through a console application using Visual Studio 2015

we were getting the below error

The fix was to specify the security protocol to be Tls12 for the connection for VS 2015 and for VS 2017 make sure the framework version is 4.6 or above.

More Details – https://support.microsoft.com/en-nz/help/4051700

Hope it helps..

Insufficient Permissions error while updating records using Excel Online in Dynamics 365

Recently one of our users reported the below while trying to bulk update the records using Excel Online feature.

The user had the Update rights for those records.

Basically, the Excel Online update features creates a data import job in the background.


So the user had to be given the import data rights.

We resolved the issue by giving the following rights to the user at organization level.

  • Data Import
  • Data Map
  • Import Source File
  • Web Wizard
  • Web Wizard Access Privilege
  • Wizard Page


Hope it helps..

The unit schedule id is missing error while trying to migrating product in Dynamics 365

Recently while trying import products from our Dev to Test environment using the Configuration Migration tool we got the below error

The reason being we were using default unit as a unit group in out DEV and the same wasn’t there in the TEST environment. Interestingly if we set the correct GUID in the data.xml generated by Configuration Migration tool and try importing, still the products do not get imported.

So basically, if we try importing the products entity alone we might run into issues. To migrate it properly we need to add the related entities along with it as mentioned in the Microsoft documentation.


We created a new schema file with Product and its related entities, and this time migration worked properly.

Hope this helps.

Sample code to hide out of the box reports using ReportVisibility class in Dynamics 365

Recently we wanted to hide OOB reports for our users.

One way of doing it is either change those report from Organization owned to personal

or change the Display in Area for those reports (this will hide those reports from all other views except the “All Reports, Including Sub Reports” view), as all other OOB Views for the reports uses the Reports Area filter. Another option of course is to update the filter criteria for those views or deactivate those views.

In our case, we simply updated the Display In property for all the OOB reports. Below is the sample code that we used. Basically, every report can have 0 or more (max 3) related Report Visibility records associated to it. (i.e. for forms, lists or reports area). In the below code we have looped through all the OOB reports and deleted all the associated ReportVisibility records for that report.

Hope it helps..

“Cannot delete an active workflow definition” error while importing solution in Dynamics 365

Recently while trying to import a solution (managed) to one of our test environments we got the below error.


The reason being one of the SLA(s) that was part of the solution was in Active stage in the test environment to which solution was getting imported.

Deactivating the SLA and then importing the solution again worked properly.

Hope it helps..

Configuration Migration Utility not migrating all the records in Dynamics 365

Recently while trying to move data for one of our entities, we saw that Configuration Migration Utility was only moving 7 records out of 11.

Even in the log, we couldn’t find any error message.

<<Drive>>:\Users\<<username>>\AppData\Roaming\Microsoft\Microsoft Dynamics® CRM Configuration Migration Utility

In fact, exporting and importing the records through excel was also only adding the 7 records.

The way we fixed this issue was by specifying the primary field of the entity as the fields to compare on update.

Running the import again this time imported all the records.

Hope it helps..

Form now showing up properly after solution import in Dynamics 365.

Recently after moving our solution from dev to test, we saw that one of our lead forms was not showing up properly.

As we can see below, the contact section is missing and the Social Pane instead of being in center is left aligned below the Summary tab label.

The fix for this was to enable the Bing Map from the System Settings in the Test.

The same record in our test, after enabling the Bing Map.

Hope it helps..

Solved – System.ArgumentNullException: Value cannot be null.Parameter name: SandboxAppDomainHelper.Execute: The plug-in type could not be found in the plug-in assembly in Dynamics 365

We got the below error while in one of our plugin assemblies. 

As it turned out we were referencing the latest, version 9 Dynamics 365 assemblies in our plugin project, against our Dynamics 365 Environment which was still in version 8.2.

Adding the appropriate NuGet Package (i.e. fixed the issue for us.

The helpful post


Hope it helps..

Microsoft.Crm.CrmException: GetAssemblyMetadata: expected mdtAssemblyRef or mdtAssembly while registering plugin assembly in Dynamics 365

While registering a plugin assembly through plugin registration tool we got the below error

The reason being we were using MSBuild.ILMerge.Task Nuget package and there were few assemblies being referenced in the plugin project that had copy local set as true.


So eventually the single plugin assembly that was getting build had these assemblies also being merged in it, which led to the above error.

Setting Copy Local as False for those assemblies fixed the issue.

Hope it helps.

Empty or Disable cache while working with Web resources in Dynamics 365 (Chrome)

Most of the time while developing Web Resource we need to frequently update and publish it. We need to make sure that it is not cached and our changes are reflected instantly on publish.

For Chrome,

Open the Developer Tools (F12)

Press and hold the reload button and select “Empty Cache and Hard Reload” to have changes reflected.


The other option à Developer tools – Settings – Preferences

Hope it helps..

Hide “Sign in with an external account” from Dynamics 365 Portal

To hide the Sign in with an external account section from the Sign In and Register page of the portal.

Set the following site settings value to false à

Followed by Restart of the portal.

To add any additional JavaScript or HTML, for e.g. we wanted to disable the Email text box on the Register page,

Go to Portals à Content Snippets and create a new code snippet record

The output:-


The helpful post –



Hope it helps..

Insufficient Security – You do not have the security priviges necessary to perform this task error while using Merge in Dynamics 365


Recently one of our users got the below error while trying to merge Lead record.

The user was having the Merge rights. However, the user was missing Share rights on the Lead entity. He already had create, write, delete, append and append to rights.

More details here


Giving Share rights fixed the issue.

Hope it helps..

Server Is Busy. The record was saved. However, the data could not be displayed because the server is busy error in Dynamics 365.

Recently one of our users got the below error

The error message is bit incorrect here. The error was because the user had User Level Read Access to the record or (Entity to be specific) and on saving the record, we had one of our real-time workflow being triggered which was assigning this record to another user. And on assignment, the record being getting assigned to another user, the user who had created\saved the record was losing the access to it.

Hope it helps..

Entities not appearing while creating\ managing the Export Profile in Data Export Service in Dynamics 365

We recently configured the Data Export Service and while creating the export profile, some of the entities were not appearing there.

We had the Change Tracking Enabled for them.

This is what it was showing to us.

Trying after few hours we got all our entities there

I think it might be caching or there is some pull mechanism that took time to detect that change at the Data Export Service side. Not sure though.

Please drop your comments if you have also faced this and know the exact reason for that.

Hope it helps.

Metadata contains a reference that cannot be resolved: ‘https://orgname.crm8.dynamics.com/XRMServices/2011/Organization.svc?wsdl&sdkversion=9’ error in Dynamics 365

We would run into this issue while trying to connect to Dynamics 365 Version 9.0 from a client application.

It is because Customer Engagement Platform (version 9.0) only supports TLS 1.2.

More details here


How we can fix it à

We need to add the following line of code to our existing code

public static OrganizationServiceProxy GetOrganizationServiceProxy()
ClientCredentials clientCredentials = new ClientCredentials();

clientCredentials.UserName.UserName = "username";
clientCredentials.UserName.Password = "password";

// Set security protocol to TLS 1.2 for version 9.0 of Customer Engagement Platform
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

return new OrganizationServiceProxy(new Uri("https://orgname.crm.dynamics.com/XRMServices/2011/Organization.svc"),
null, clientCredentials, null);

Helpful post




Hope it helps..

User does not have the privilege to act on behalf another user error while using impersonation in Web API in Dynamics 365.

We might receive below error while using impersonation in Web API call.

{\r\n  \”error\”:{\r\n    \”code\”:\”\”,\”message\”:\”User does not have the privilege to act on behalf another user.\”,\”innererror\”:{\r\n      \”message\”:\”User does not have the privilege to act on behalf another user.\”,\”type\”:

Impersonation in Web API


This error can occur in a scenario when User A is trying to impersonate User B, but user A doesn’t have “Act on Behalf of Another User” privilege.

Below article nicely explains it


Hope it helps..

A security error has occurred. Make sure you are signed into Microsoft Dynamics CRM and try again in Click Dimensions.

We had this issue in past when we started getting below error in most of the entities of Click Dimensions.

The issue can occur if the password would have expired or changed for the Service Credentials account of Click Dimensions.

Go to Settings à ClickDimensions Settings à Service Credentials.

In our case it wasn’t changed but we were still getting the issue. The only way we were able to fix it was to specify a different account for the Service Credentials.

Hope it helps.

Plugin on AddListMembers message. When does it fire?

In one of our recent implementations involving marketing list entity, we were analysing the AddListMembers message for it.

We registered a plugin on AddListMembers message and below were our findings.

  • Dynamics Marketing List – The plugin didn’t trigger.
  • Static Marketing List – The plugin didn’t trigger for “Add using Lookup“. It only triggered for “Add using Advanced Find” when “Add only the selected members to the marketing list” option was selected. It didn’t trigger for “Add all the members returned by the search to the marketing list


This slideshow requires JavaScript.

So basically, we need to be very careful while implementing a plugin on AddListMembers message.

Hope it helps..

Auto-Closure of Task considering Work Hours and Holidays in Dynamics 365

Auto-Closure of Task considering Work Hours and Holidays in Dynamics 365.

Recently we had a requirement to auto close the task after 2 days of due date passed. Here we had to consider work hours and holidays as well.

The good thing was that with SLA considering both work hours and holidays, we could implement this without writing a single piece of code.

Below are the steps to implement it –

Enable SLA for Task

Navigate to Settings à Service Management à Click on Service Level Agreement and create a new SLA against Task.

Create a new SLA record with following details.

Here we need to specify Business Hours in our SLA. For this, we will be creating a Customer Service Schedule record which observes the holiday.

So let us first define a new Holiday Schedule.

Navigate to Settings à Service Management and click on Holiday Schedule.

This holiday schedule will be used while defining Customer Service Schedule.

Create a holiday schedule record and add holiday records to it.

Here we have added a sample holiday of 2 days.

Now let us define the Business Hours.

Navigate to Settings à Service Management à Customer Service Schedule

Create a new schedule

Set Workdays as Mon – Friday and work hours as 8 – 5 P.M. and select our Holiday Schedule record created earlier.

Let us update our SLA record with these new customer service schedule.

Let us try creating a new SLA Item record. Here we will find that there is no KPI’s defined i.e. SLA KPI drop down doesn’t have any value.

Let us define an SLA KPI here.

For defining KPI we need to create a new relationship between Task and SLA KPI Instance (n-1 i.e. Many to 1).

Open the Task form for customization and add this new lookup SLA KPI Instance on the form.

Next, add a Quick View Form of SLA KPI entity in it.

Click on Edit to update the Resolve By SLA quick view form to add a new field Failure Time in it.

Add the Quick View Form to the Task form.

Back in our SLA item,

  • Select the new KPI created.
  • Specify Applicable as when status reason not equal to either completed or cancelled.
  • Failure after 18 hours i.e. 2 Days (as we specified 9 hours working in Customer Service Schedule)
  • Warning as 9 hours.


  • Activate and Set as Default.

Creating a task with Due Date will start the Timer for Resolve In.

In the task record created we have set the Due Date to 22nd Nov 8 A.M. and we can see the resolve by date to be 27th.

In our SLA we had set the Failure After as 18 hours, and the holiday was set on 23rd and 24th. And also 25th and 26th being Sat-Sun the Failure Time comes as 27th Monday, which is exactly what we want.

Another interesting way of implementing the same without using SLA.


Hope it helps..

“the requested formId is not a valid form to display for this user” exception while opening a record inside Dynamics 365.

Recently while opening a marketing list record inside Dynamics 365, we got the below issue.

The issue was because we had multiple marketing list forms and the one the user had accessed last had all the security roles removed from it.

Enabling the security role that user had, for that particular form fixed the issue.

Hope it helps..

Implementing “Does not contain data” for N – N relationships through RetrieveMultiple plugin in Dynamics 365

Recently we had a requirement to create a marketing list with members (contact) which are not part of any other marketing list through Advanced Find.

In version 9.0 we have “Does not contain data” filter added in Advanced Find. However, it works only in case of 1 – N relationship.


Here in our case, it is an N-N relationship between Contact and Marketing List.

The solution we implemented was following –

We asked the user to select the following condition in their Advanced Find query.

Which will have the following fetch XML à

And in our Retrieve Multiple Plugin, we added a new filter condition and replaced link entity condition as shown below for implementing the outer join.

Below is the sample code for the plugin that achieves this. The plugin is Registered on Pre Retrieve Multiple of Contact.

The code –

public class PreRetrieveMultipleML : IPlugin
public void Execute(IServiceProvider serviceProvider)
// Obtain the execution context from the service provider.
IPluginExecutionContext context = (IPluginExecutionContext)

// Obtain the organization service reference.
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));

// The InputParameters collection contains all the data passed in the message request.
if (context.InputParameters.Contains("Query") && context.InputParameters["Query"] is QueryExpression && context.MessageName == "RetrieveMultiple")
var query = (QueryExpression)context.InputParameters["Query"];

tracingService.Trace("Inside Plugin");

if (query != null && query.EntityName == "contact")
foreach (var linkedEntity in query.LinkEntities.Where(
a =>
a.LinkFromAttributeName.Equals("contactid") &&
a.LinkToAttributeName.Equals("entityid") && a.LinkToEntityName.Equals("listmember") &&
a.LinkEntities.Count == 1 && a.LinkEntities[0].LinkCriteria != null))
if (linkedEntity.LinkEntities[0].LinkCriteria.Conditions.Count == 1
&& linkedEntity.LinkEntities[0].LinkCriteria.Conditions[0].AttributeName.Equals("listid")
&& linkedEntity.LinkEntities[0].LinkCriteria.Conditions[0].Operator == ConditionOperator.Null)
// remove the existing link entity

// create a new link entity
LinkEntity doesNotContainLinkEntity = new LinkEntity()
EntityAlias = "ml",
LinkFromEntityName = "contact",
LinkToEntityName = "listmember",
LinkFromAttributeName = "contactid",
LinkToAttributeName = "entityid",
JoinOperator = JoinOperator.LeftOuter

// add the newly created link entity

// create a new condition expression
var doesNotContainCondition = new ConditionExpression();
doesNotContainCondition.AttributeName = "listid";
doesNotContainCondition.Operator = ConditionOperator.Null;
doesNotContainCondition.EntityName = "ml";

//create a new filter condition
var doesNotContainFilterExpression = new FilterExpression();

// add this new filter in query


We can update the plugin’s code to be used for any other N-N relationship similarly.

Hope it helps..

“Register a New WebHook” through Plugin Registration Tool in Dynamics 365

With July 2017 Update, now we have the option to register a new Webhook through Plugin Registration tool.

Download the latest Plugin Registration Tool from NuGet using the PowerShell script à


Through registering a Webhook, we can send data (execution context) about any operation performed on Dynamics 365 to the external services or application. The execution context information is passed in JSON format here.

More details here


Let us take a simple scenario to see it in action.

First will create an Azure Webhook which passes the Execution Context to the Azure Service Bus Queue. We will also create a sample Queue Listener application that parses and reads the information from the queue.

  • Create a new Function of type Webhook + API (CSharp).

  • Select Integrate in the newly created function and click on New Output button and add Azure Service Bus as an output.

  • Specify Message type as Service Bus Queue and other required values like Service Bus Connection, Queue Name and the parameter name and click on Save.
  • Update the code for our function to pass the execution context information to the queue
  • Now let us register our Webhook inside Dynamics 365. For this copy the function URL using Get function URL button.

  • Click on Copy.

  • Inside Plugin Registration tool, click on Register à Register New Web Hook.

  • Specify any Name for the Webhook. In the Endpoint URL, paste the URL copied without any query string part. For Authentication select WebhookKey and paste the “code” query string value to register the Webhook.

  • Register a new step of Lead Create to it.

  • After registering the step, to test our Webhook Function, let us create a new lead record inside Dynamics 365.

  • Back in our function, click on Monitor to check the log. There we can see the execution context information passed to our function.

  • Inside the Queue specified as Output of the function, we can see the new messages added.

  • Below is the sample code to read the message from the queue.

private static void QueueClientExample()
// create a new Shared Access Policy for the queue
// set the connection string of the Shared Access Policy created
var connectionString = "Endpoint=sb://[namespace].servicebus.windows.net/;SharedAccessKeyName=MyPolicy;SharedAccessKey=[KeyValue];EntityPath=mycrmqueue";

// create the Queue Client object
var client = QueueClient.CreateFromConnectionString(connectionString);

// get the message from the Queue Client
BrokeredMessage brokeredMessage = client.Receive();

var stream = brokeredMessage.GetBody<Stream>();
StreamReader streamReader = new StreamReader(stream);
string jsonData = streamReader.ReadToEnd();
jsonData = jsonData.Replace(@"\", string.Empty).Trim(new char[] { '\"' });
JObject context = JObject.Parse(jsonData);

Console.WriteLine("Primary Entity Name = " + context["PrimaryEntityName"] + " Message Name = " + context["MessageName"]);


  • The output

More on Azure Functions à


Similar example using Azure Service Bus Integration à


Hope it helps..

Sample Code for Autonumbering in Dynamics 365 July 2017 Update

As a first step, add references to the latest version 9 assemblies


In the below sample code, we are creating an Auto number attribute in Contact Entity.

This is how the fields shows up inside contact form.

Using UpdateAttribute Request we can update the format for the AutoNumber field.

And also, we can have multiple auto number fields for an entity as shown below.

Sample Code

CreateAttributeRequest createAttributeRequest = new CreateAttributeRequest();
createAttributeRequest.EntityName = "contact";

var autoNumberAttributeMetadata = new StringAttributeMetadata()
AutoNumberFormat = "Auto Number - {SEQNUM:4} - {RANDSTRING:4} - {DATETIMEUTC:yyyyMMddhhmmss}",
SchemaName = "new_autonumber1",
MaxLength = 100,
RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.ApplicationRequired),
DisplayName = new Microsoft.Xrm.Sdk.Label("My Auto Number", 1033),
Description = new Microsoft.Xrm.Sdk.Label("This is my first auto number field through SDK", 1033)

createAttributeRequest.Attribute = autoNumberAttributeMetadata;
var response = organizationService.Execute(createAttributeRequest);

And now the simplest and best way to create these Auto Number fields à

Using Auto Number Manager developed by Jonas Rapp, Microsoft MVP.




Hope it helps..

Dynamics 365 Relationship Insights-An error has occurred. Error ID :: InvalidTenantProductId in Dynamics 365 July 2017 Update

While trying to configure Relationship Insights in Dynamics 365 July 2017 Update

I am getting the below issue.

Is anyone else facing the same ?

Members Count field not getting updated on converting Dynamic Marketing List to Static Marketing List – issue in Dynamics 365 July 2017 Update

While trying out few things in July 2017 update of Dynamics 365, we encountered a strange issue.

The members count field was properly in case of Static Marketing List, however, while converting the Dynamic Marketing List to Static (using Copy To Static), this field was not getting populated.

And also, the field was getting unlocked in case of Update Form for both Static and Dynamic Marketing list, unlike earlier version where this field was always locked on Form.

The field properly calculating count and locked in case of earlier versions.

Hope it helps..

A validation error occurred. The value of ‘membercount’ on record of type ‘list’ is outside the valid range exception in Dynamics 365 (CRM)

We were getting the below error while trying to delete one of the marketing list members from a static marketing list.

This occurs if the Members Count field has value 0 in it, even if there are members associated to it. (due to some exception)

Updating that field to correct value fixes this issue (customize the form to add the field on form). and we can then delete the members from it.

Hope it helps..

“Does not contain data” filter in Advanced Find in Dynamics 365 July 2017 Update

With July 2017 Update in Dynamics 365, Advanced Find view now supports Does Not Contain Data filter for related record.

So basically, we can now write a query like “Find all the lead records which doesn’t contain any related task”. However, we cannot define any filter conditions for the related record though.

The other interesting thing that we observed that in the case of N – N relationships it throws exception.

For e.g. if we want to find all the contacts that are not associated to marketing list

We get the following exception à


The does not contain data filter isn’t available while defining marketing list members in marketing list.

Hope it helps..