CRM 2016 back button built-in within record

December 11, 2015 Leave a comment

As many of as come across the situation where we have to go back to previous screen from the current record. In order to that in crm 2011/2013/2015 we have to click on browser back button. But in crm 2016 there is a “X” in the top right corner of the record by clicking on it, it takes you to the previous screen that you were working.  This works even if you opened any record from subgrid/lookup, By clicking “X” button in opened record it takes you to the parent record.  This button works taking you up to list view as there is no “X” button in list view if you want to go beyond this then you have to use browser back button. I tried multi level like going from account ->case subgrid record -> case-> case primary record lookup->opening contact owner and by clicking this button it took me back up to account list view. Really its a cool future and will avoid multiple clicks that we used to do in the past



Categories: CRM 2016

Auto Create Sharepoint Folder in CRM online

October 2, 2015 11 comments

Many of our customers annoyed and frustrated with popup that appears when they click on documents navigation link on a record to add documents. So I thought it can be easily addressed  using workflow/plugin on create of record by automatically adding the SharePoint location record.But that did not resolve problem still users prompted with popup. When  i googled on this topic i found one post from Scott but that requires to have user name and password of the sharepoint admin.

After lot of trial and error just started with my best friend fiddler to capture request and response that were posted on click of the popup window.  CRM online uses CRM API message “CreateFolder”  to create sharepoint folder and location record. I tried to use this “CreateFolder” message in my custom workflow step to create folder but received error message “This requested can’t be executed in sandbox mode”  then tried with javascript to post same message and it worked fine.

Here is complete script to auto create sharepoint folder for CRM online. Add below script to your script resource file and save  and publish it.  Then call function createDocFolder on onload of the page that will automatically create sharepoint and location folder.

//Function to be called on onload of the page.
var myFormType = null;
function createDocFolder() { () {
            myFormType = Xrm.Page.ui.getFormType();
       if (myFormType === 1 && Xrm.Page.ui.getFormType() !== 1) { // calls this method only when new record is saved.
           var clientUrl = Xrm.Page.context.getClientUrl();
           var xmlhttp = new XMLHttpRequest();
 “POST”, clientUrl + “/XRMServices/2011/Organization.svc/web”, false);
           xmlhttp.setRequestHeader(“Accept”, “application/xml, text/xml, */*”);
           xmlhttp.setRequestHeader(“Content-Type”, “text/xml; charset=utf-8”);
           xmlhttp.setRequestHeader(“SOAPAction”, “”);
           xmlhttp.onreadystatechange = function () {
         if (xmlhttp.readyState == 4 && xmlhttp.status != 200) {
                      alert( xmlhttp.responseText);

//Function to build request

function buildCreateReq() {
var recordId =“{“, “”).replace(“}”, “”);
return “<s:Envelope xmlns:s=\”\”>” +
” <s:Header>” +
” <SdkClientVersion xmlns=\”\”></SdkClientVersion>” +
” </s:Header>” +
” <s:Body>” +
“<Execute xmlns=\”\” xmlns:i=\”\”>” +
” <request i:type=\”b:CreateFolderRequest\” xmlns:a=\”\” xmlns:b=\”\”>” +
” <a:Parameters xmlns:b=\”\”>” +
” <a:KeyValuePairOfstringanyType>” +
” <b:key>FolderName</b:key>” +
” <b:value i:type=\”c:string\” xmlns:c=\”\”>” + + “_” + recordId + “</b:value>” +
” </a:KeyValuePairOfstringanyType>” +
” <a:KeyValuePairOfstringanyType>” +
” <b:key>RegardingObjectType</b:key>” +
” <b:value i:type=\”c:int\” xmlns:c=\”\”>” + Xrm.Page.context.getQueryStringParameters().etc + “</b:value>” +
” </a:KeyValuePairOfstringanyType>” +
” <a:KeyValuePairOfstringanyType>” +
” <b:key>RegardingObjectId</b:key>” +
” <b:value i:type=\”c:string\” xmlns:c=\”\”>” + recordId + “</b:value>” +
” </a:KeyValuePairOfstringanyType>” +
” <a:KeyValuePairOfstringanyType>” +
” <b:key>DocumentType</b:key>” +
” <b:value i:nil=\”true\” />” +
” </a:KeyValuePairOfstringanyType>” +
” <a:KeyValuePairOfstringanyType>” +
” <b:key>ParentLocationId</b:key>” +
” <b:value i:nil=\”true\” />” +
” </a:KeyValuePairOfstringanyType>” +
” </a:Parameters>” +
” <a:RequestId i:nil=\”true\” />” +
” <a:RequestName>CreateFolder</a:RequestName>” +
” </request>” +
“</Execute>” +
“</s:Body>” +

Click here to Download script File, change the extention of the file to js from doc.



Categories: MS CRM 2015

Power shell Cmd to create Forward inbox rule for Email Router – ForwardAsAttachmentTo

Below Power shell cmd will come handy if you want to quickly add forward inbox rule for multiple mailbox in Email Router. If you have 500 mailbox to deploy this rule it will take just 10 seconds to execute compared to 30 minutes in rule deployment wizard

Command :

New-InboxRule -name “ToCRM” -mailbox SourceMailboxEmail -ForwardAsAttachmentTo ForwardmailboxEMail

“ToCRM” – Rule Name just for identification
“SourceMailboxEmail” – Actualmailbox which will forward email as an attachment to the forward mailbox eg:

“ForwardmailboxEMail” – forward mailbox emaill address where all the emails forwarded ef:

You could use Rule deployment wizard but it takes lot of time also if you have more than 25 mailbox and want to deploy rule for selected mailbox it gets to time consuming process.

Categories: MS CRM 2015

Behavior of Roll-Up and Calculated Fields in Quick view Form

July 1, 2015 2 comments

1. Roll-up field will not show value in a quick view form. It will be always empty

2. Calculated field will show  right value in a Quick view form

I had requirement to show calculated and roll-up fields of an lookup record in a form. I thought using quick view form it will be 5 minutes of work. But for my surprise quickview form shows all the fields of an lookup record with values except roll-up fields.  I thought it might be because of  lookup record has null value in roll-up field. But that’s not the case  when i opened lookup record it shows value in the roll-up field.

It seems like product bug when you add roll-up field in a quickview form it never  shows value.

So don’t use roll-up field in a Quick view form, You can add Calculated field in a quick view form and it works with out any issue.

Categories: Uncategorized

Set Unresolved Email in party List using Java Script

While doing google search this morning i found below trick to set unresolved email address on the partylist lookup field

function setUnresolvedRecipient(unresolvedemail) {
        var obj = new Object(); //create the unresolved object = unresolvedemail;
        obj.category = 3; = unresolvedemail;
        obj.type = "9206";
        var toField = Xrm.Page.getAttribute("to");
        var toValue = toField.getValue();
        if (toValue != null) {
            toValue.push(obj); //if there are already other values, add to it
        else {
            toField.setValue([obj]); //if 'to' field is null, just override it
Categories: MS CRM 2015

RetrievePrivilegeForUser failed – no roles are assigned to user

April 24, 2015 1 comment

I had a very interesting issue this morning in one of our on-premise dev environment.  Issue was all of sudden one of our organization not accessible at all , i was able to access other organization on the same server. Same error message was shown to all the user regardless user has admin or ordinary user role.  I stumbled for sometime with this issue then enabled crm trace to capture actual error message. The error message was

“Crm Exception: Message: SecLib::RetrievePrivilegeForUser failed – no roles are assigned to user Returned hr = -2147209463, User: fe0d891a-87ea-e411-80d4-00155d016008, ErrorCode: -2147209463” . I knew I have system administrator role though i just verified this by querying the sql server. Then i queried crm for an user with guid shown in the trace log. Sql returned user name of the Guid that is not at all my user name that’s service account name used in CRM App pool of IIS.

When googled with this error message I found a Microsoft KB article with exact error message

Issue :

By default, when a CRM user is created in Microsoft Dynamics CRM, the user has no security roles. Because the CRM service account is mapped with the newly created user, the CRM service account cannot operate anything. Therefore, the system crashes.

This behavior is by design. Making the account that is running the CRMAppPool into a Microsoft Dynamics CRM user is not supported.


Keep the CRM service account as a dedicated service account.

Kb article explains the issue  but it does not provide resolution to fix the issue.

To fix this issue  i followed below steps

1.Disabled Organization using deployment manager

2.Once disabled, deleted the organization from the deployment Manger

3.Re-imported the organization , while re-importing in user mapping step removed service account user ( CRM App pool)  mapping and and kept all other user mapping as it is.

Once Organization imported everything worked like a charm.

The real story is, one of our new team memebr added service account as a crm user that caused this issue.

Change Label Position in Quick View form

February 7, 2015 Leave a comment

In any entity Main Form we can customize the Field label position for the section  Either Side or Top. For example if you want to show label of the field in the top you can do this by selecting the section properties and in format tab under “Field Label Position” you can choose top.


Same way you can change Field label position to “Side” to display label in the left side of the field. When we form with fields and  Quick view form, where all form Field Label position is set to Top ,

Still quick view form shows filed label in the left and it does not look good in the form. If you try to change the quick view form Field label position there is no option in the UI customization section.

To change the Quick view form “Field Label Position” to Top  or vise versa you can follow the below steps

1. Create new solution  and the quick view form entity to the solution. ( Eg : For Contact Quick view  , Add contact entity to the solution )

2.Export the solution and unzip the solution.

3.Copy the Customization.xml from the zip fle and open the customization.xml in any text editor

4. Find the quick view form in the customization XMl, in the form locate the <tabs><sections> tag and corresponding <section> tag that you want to change Field Label Position. ( For example Information section in contact Quick view form)

5. in the section xml tag add celllabelposition=”Top” attribute to show label in top of the field and celllabelposition=”Left” to show label in the left. Showing label in left is the default behavior.


6.After adding this attribute to the Xml save the customization.xml and place this xml file back to solution and import into system and publish it.

Here is the final result  where Filed labels placed in top of the field in Quick view form


Here is sample customization.Xml file that i have used to change ” Contact quick view” form to show label in the top

<forms type=”quick”>
<form hasmargin=”false” shownavigationbar=”false”>
<ancestor id=”{bdb0ae1c-32fa-4374-b637-8dafe107bc44}” />
<tabs showlabels=”false”>
<tab name=”general” verticallayout=”true” id=”{6fd9013a-2c88-4593-b364-c9f21e572640}” IsUserDefined=”0″>
<label description=”General” languagecode=”1033″ />
<column width=”100%”>
<section name=”information” id=”{a9d2c4bb-9863-4712-b13c-f27c88331597}” IsUserDefined=”0″ showlabel=”false”
showbar=”false” celllabelposition=”Top”>


If it’s a default system quick view form system may not export the quick view form as part of the solution. In order to system export the quick view form, add any field to the quick  view form and save and publish it . If you export the solution now , system will export the quick view form as part of the solution.

Categories: Uncategorized