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

X_button1

 

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.

http://develop1.net/public/post/SharePoint-Integration-Reloaded-e28093-Part-3.aspx

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() {
        Xrm.Page.data.entity.addOnSave(function () {
            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();
           xmlhttp.open(“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”, “http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute”);
           xmlhttp.onreadystatechange = function () {
         if (xmlhttp.readyState == 4 && xmlhttp.status != 200) {
                      alert( xmlhttp.responseText);
        }
     };
     xmlhttp.send(buildCreateReq());
     }
}

//Function to build request

function buildCreateReq() {
var recordId = Xrm.Page.data.entity.getId().replace(“{“, “”).replace(“}”, “”);
return “<s:Envelope xmlns:s=\”http://schemas.xmlsoap.org/soap/envelope/\”>” +
” <s:Header>” +
” <SdkClientVersion xmlns=\”http://schemas.microsoft.com/xrm/2011/Contracts\”></SdkClientVersion>” +
” </s:Header>” +
” <s:Body>” +
“<Execute xmlns=\”http://schemas.microsoft.com/xrm/2011/Contracts/Services\” xmlns:i=\”http://www.w3.org/2001/XMLSchema-instance\”>” +
” <request i:type=\”b:CreateFolderRequest\” xmlns:a=\”http://schemas.microsoft.com/xrm/2011/Contracts\” xmlns:b=\”http://schemas.microsoft.com/crm/2011/Contracts\”>” +
” <a:Parameters xmlns:b=\”http://schemas.datacontract.org/2004/07/System.Collections.Generic\”>” +
” <a:KeyValuePairOfstringanyType>” +
” <b:key>FolderName</b:key>” +
” <b:value i:type=\”c:string\” xmlns:c=\”http://www.w3.org/2001/XMLSchema\”>” + Xrm.Page.data.entity.getPrimaryAttributeValue() + “_” + recordId + “</b:value>” +
” </a:KeyValuePairOfstringanyType>” +
” <a:KeyValuePairOfstringanyType>” +
” <b:key>RegardingObjectType</b:key>” +
” <b:value i:type=\”c:int\” xmlns:c=\”http://www.w3.org/2001/XMLSchema\”>” + Xrm.Page.context.getQueryStringParameters().etc + “</b:value>” +
” </a:KeyValuePairOfstringanyType>” +
” <a:KeyValuePairOfstringanyType>” +
” <b:key>RegardingObjectId</b:key>” +
” <b:value i:type=\”c:string\” xmlns:c=\”http://www.w3.org/2001/XMLSchema\”>” + 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>” +
“</s:Envelope>”;
}

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

createdocumentfolder.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: chitra@microsoft.com

“ForwardmailboxEMail” – forward mailbox emaill address where all the emails forwarded ef: emailrouter@microsoft.com

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

http://mscrmbi.blogspot.com/2014/03/set-unresolved-email-ids-in-party-list.html

function setUnresolvedRecipient(unresolvedemail) {
        var obj = new Object(); //create the unresolved object
        obj.name = unresolvedemail;
        obj.category = 3;
        obj.data = 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
            toField.setValue(toValue);
        }
        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

https://support.microsoft.com/en-us/kb/2500917/

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.

Resolution:

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.

2015-02-06_2345

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.

2015-02-06_2358

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

2015-02-07_0008

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”>
<systemform>
<formid>{bdb0ae1c-32fa-4374-b637-8dafe107bc44}</formid>
<IntroducedVersion>5.0.0.0</IntroducedVersion>
<FormPresentation>0</FormPresentation>
<FormActivationState>1</FormActivationState>
<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″>
<labels>
<label description=”General” languagecode=”1033″ />
</labels>
<columns>
<column width=”100%”>
<sections>
<section name=”information” id=”{a9d2c4bb-9863-4712-b13c-f27c88331597}” IsUserDefined=”0″ showlabel=”false”
showbar=”false” celllabelposition=”Top”>

NOTE : 

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