Route Case (routecase) attribute and msdyn_ApplyRoutingRuleEntityRecord Action in Dynamics 365 Customer Service

The case entity/table in Dynamics 365 CE has a Boolean type field named Route Case.

It has a default value as Yes.

On manually creating the record from the user interface, although Route Case shows the default value as Yes

On saving the record, the value changes to No, the field is also locked.

So basically no routing rules are applied when a case record is created from the user interface.

To apply routing rules, we need to use the “Save and Route” option

Or “Apply Routing Rule” command from the Grid

This also however will not update or set the Route Case field to Yes on the case record.

Now if we create the case record programmatically, the field would be set and saved with its default values as Yes.

The same goes for cases created from Flow.

Route Case is set to Yes.

So basically routing rules will be triggered on the records created from outside the User Interface as Route Case will be set Yes for those records.

Now if we want to run the routing rules against the case record created from the user interface, we can make use of the following action –


Within Flow –

Within Plugin or any custom code–

msdyn_ApplyRoutingRuleEntityRecord can be used for other entities apart from the case.

In the case of Case entity, we can also make use ApplyRoutingRule action also.

Hope it helps..



Unexpected error (SQL Timeout error) while trying to delete Audit Log

Unexpected error (SQL Timeout error) while trying to delete Audit Log

We had around 200 GB of Audit Log data in our Production Environment (Online), but while trying to delete it through Audit Log Management resulted into unexpected error.

The only option is to raise the support ticket with Microsoft. We also raised the same but it unfortunately resulted in our Production Server being down for brief period of time because of time out issue while performing the operation in Audit Base.

So, in short if we are facing issue while deleting log ourselves, we need to raise the support ticket and also the plan the same during downtime or weekends when users are not using the system.

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.

Configure Session Timeout and Inactivity Timeout – Dynamics 365

In Dynamics 365, we can now define Session timeout and Inactivity timeout.

We need to go Settings à Administration à System Settings à General Tab

By default, the session timeout is set to 24 hours along with 20 minutes for warning the user.

We can set our custom values there.

Enter maximum session length 60 – 1440 minutes. ( 1 to 24 hour)
How long before the session expires do you want to show a timeout warning? 20 – 1440 minutes. Must be less than maximum session length.

We can also set the timeout based on inactivity. By default, this setting is not enabled. Below are the values that we can set for inactivity timeout.

Enable session timeout due to inactivity 5 – 1440 minutes. (5 minutes to 24 hours) – Must be less than the maximum session length.
How long before the session expires do you want to show an inactivity warning? Less than Session timeout due to inactivity

Session Timeout warning à

Session expired à

Inactivity warning à

Inactivity Session expiration à

More details.

Hope it helps..

Sample code to retrieve more than 5000 records using FetchXML in CRM


Sharing a sample code to retrieve more than 5000 records using the Fetch XML.

Version 1 :

<p>private List&lt;Entity&gt; GetTotalRecordsfromFetch(string fetchXML, IOrganizationService orgService)<br />
{<br />
List&lt;Entity&gt; lstEntity = new List&lt;Entity&gt;();</p>
<p>int fetchCount = 5000;<br />
int pageNumber = 1;<br />
string pagingCookie = null;</p>
<p>while (true)<br />
{<br />
// Build fetchXml string with the placeholders.<br />
string xml = this.CreateXml(fetchXML, pagingCookie, pageNumber, fetchCount);<br />
RetrieveMultipleRequest fetchRequest = new RetrieveMultipleRequest<br />
{<br />
Query = new FetchExpression(xml)<br />
<p>var returnCollections = ((RetrieveMultipleResponse)orgService.Execute(fetchRequest)).EntityCollection;</p>
<p>if (returnCollections.Entities.Count &gt;= 1)<br />
{<br />
lstEntity.AddRange(returnCollections.Entities);<br />
<p>if (returnCollections.MoreRecords)<br />
{<br />
<p>results.pagingCookie = returnCollections.PagingCookie;<br />
}<br />
else<br />
{<br />
// If no more records in the result nodes, exit the loop.<br />
break;<br />
}<br />
<p>return lstEntity;<br />
<p>public string CreateXml(string xml, string cookie, int page, int count)<br />
{<br />
StringReader stringReader = new StringReader(xml);<br />
XmlTextReader reader = new XmlTextReader(stringReader);</p>
<p>XmlDocument doc = new XmlDocument();<br />
<p>XmlAttributeCollection attrs = doc.DocumentElement.Attributes;</p>
<p>if (cookie != null)<br />
{<br />
XmlAttribute pagingAttr = doc.CreateAttribute("paging-cookie");<br />
pagingAttr.Value = cookie;<br />
attrs.Append(pagingAttr);<br />
<p>XmlAttribute pageAttr = doc.CreateAttribute("page");<br />
pageAttr.Value = System.Convert.ToString(page);<br />
<p>XmlAttribute countAttr = doc.CreateAttribute("count");<br />
countAttr.Value = System.Convert.ToString(count);<br />
<p>StringBuilder sb = new StringBuilder(1024);<br />
StringWriter stringWriter = new StringWriter(sb);</p>
<p>XmlTextWriter writer = new XmlTextWriter(stringWriter);<br />
doc.WriteTo(writer);<br />
<p>return sb.ToString();<br />

Version 2 :

<p>private static List&lt;Entity&gt; GetTotalRecordsFetchXML(OrganizationServiceProxy orgProxy, string fetchXML)<br />
{<br />
XDocument xDocument = XDocument.Parse(fetchXML);<br />
var fetchXmlEntity = xDocument.Root.Element("entity").ToString();</p>
<p>EntityCollection entityColl = new EntityCollection();<br />
List&lt;Entity&gt; lstEntity = new List&lt;Entity&gt;();<br />
int page = 1;<br />
do<br />
<p>entityColl = orgProxy.RetrieveMultiple(new FetchExpression(<br />
string.Format("&lt;fetch version='1.0' page='{1}' paging-cookie='{0}'&gt;" + fetchXmlEntity + "&lt;/fetch&gt;",<br />
SecurityElement.Escape(entityColl.PagingCookie), page++)));</p>
<p>lstEntity.AddRange(entityColl.Entities);<br />
}<br />
while (entityColl.MoreRecords);</p>
<p>return lstEntity;<br />

Hope it helps..


Using Shared Mailbox and Queue in CRM for implementing generic email address in Dynamics 365 and Exchange Online.

Recently, we had a requirement to send email to customers using a generic email address like from Dynamics CRM (& Exchange Online).

The way we can implement this is through Shared Mailbox and Queue in CRM Online.

Log in to the Administration Portal

Select Shared mailboxes

Members can be added to the Shared Mailbox

Now back in CRM assign the email id to a particular queue.

Now sending an email activity with From as Queue and to as one of the user inside CRM.

Open the user’s mail box.

Make sure we have done Test and Enabled Mailbox for the Shared Email Box and have set Incoming and Outgoing Email as Server-Side Synchronization.

Hope it helps..

%d bloggers like this: