Archive

Archive for June, 2012

Fix – Unable to add custom Report to the Solution in CRM 2011

June 30, 2012 1 comment

I have a custom SSRS report “ABC Report” in my CRM application.

ABC Report

ABC Report

And, I wanted to include this report in my solution “My Reports” and export to another CRM organization

But to my surprise, I did not find “ABC Report” when I choose “Solution -> Reports  ->  Add existing”

Add existing reports - solution

Add existing reports – solution

Fix :-

  • Go to “Work Place -> Reports”
  • Choose “ABC Report” and click “Edit”
  • In the report window go to “Administration” tab
  • Set Report “Viewable By” option to “Organization” and Save
Set “Viewable By” option to “Organization”
Set “Viewable By” option to “Organization”
  • Open the solution and click “Reports à Add existing reports”
"ABC Report" in the list

“ABC Report” in the list

🙂

Object doesn’t support this property or method XMLHttpRequest error – FIX

Hi,

I was getting “object doesn’t support this property or method jquery” error when I was initializing

var request = new XMLHttpRequest();

Reason :-

  • This is a problem with Internet Explorer browser (ActiveX to be precise)

Fix :-

  • If the browser is detected as Internet Explorer, load ActiveX instead of XMLHttpRequest
  • Below condition check would solve the problem

var request;

if ($.browser.msie) {

request = new ActiveXObject(“Microsoft.XMLHTTP”);

} else {

request = new XMLHttpRequest();

}

🙂

Address entity in CRM 2011

June 24, 2012 1 comment

Below are few useful points about “Address“ in CRM

  • In CRM, “Account” and “Contact” entities have built-in fields to capture two sets of addresses.
    • These fields are address1_street1, address1_city, address1_stateorprovince, etc., as well as another whole set for address2 fields.
    • We normally assume that 2 default set of address fields have been added on the account/contact entity.
    • But this not really the case. All addresses are only stored in the “Customer Address” entity.
  • When you create a new account/contact, it would by default in the background add 2 records in the “Customer Address” entity for the 2 set of address fields available on the Account form.
    • CRM distinguishes these entries from the rest of the entries to be displayed in More addresses using the Address number column.
    • Address number 1 and 2 are reserved for the 2 set of address fields available on the account form.
Customer Address

Customer Address

  • Along with these 2 sets, we also have “More Addresses” link on the both Account\Contact navigation area
  • The first two Address records that the platform creates are hidden in the “More Addresses” associated view on the Account or Contact
  • Addresses are not available on Security Roles
  • You cannot update the Address record via workflow

Security Over Address :-

  • The security access to the Address entity is tied directly with that of “Account”entity.
    • e.g. For the Contact entity, the user will only be able to see the “More Addresses” in the left nav only if the user has “Read” access to the Account entity.
    • If you want to allow the user to “Add New Address” on the Contact form,
      • Grant “Create” and “Append” access for Account entity and “Append To” access on the Contact entity.
      • Granting “Write” access to Account entity will allow the user to edit the Addresses.

🙂

Checking whether user part of team using jscript CRM 2011

June 23, 2012 2 comments

Hi,

We can verify whether the User is part of particular Team using jscript.

Below is the jscript function

function isUserPartOfTeam(userId, teamId) {

var oDataEndpointUrl = serverUrl + “/XRMServices/2011/OrganizationData.svc/”;

oDataEndpointUrl += “TeamMembershipSet?$select=BusinessUnitId&$filter=TeamId eq guid'” + teamId + “‘ SystemUserId eq guid'” + userId + “‘”;

var service = GetRequestObject();

if (service != null) {

service.open(“GET”, oDataEndpointUrl, false);

service.setRequestHeader(“X-Requested-Width”, “XMLHttpRequest”);

service.setRequestHeader(“Accept”, “application/json,text/javascript, */*”);

service.send(null);

var requestResults = eval(‘(‘ + service.responseText + ‘)’).d;

if (requestResults != null && requestResults.results.length > 0) {

return true;

}

}

return false;

}

How do I call this method :-

  • Pass User Id & Team Id to the function.
  • Function returns true/false

var userId={User GUID};

var teamId={Team GUID};

var flag= isUserPartOfTeam(userId, teamId);

🙂

Reading WCF client binding configurations from plug-in

June 16, 2012 1 comment

In one of my requirement I have to call my custom WCF service method from plug-in.

In this scenario my plug-in is WCF client and I have to read client binding configuration from plug-in.

Below are the ways you can read the binding configuration details from plug-in

  • Synchronous plug-in
    • In case of synchronous plug-in, you can place binding configuration in root <web.config> file of CRM application server
    • Open the Web.config from path “C:\Program Files\Microsoft Dynamics CRM\CRMWeb\web.config
    • Find <System.ServiceModel> node and place the client binding configuration
    • After placing the configuration, the <System.ServiceModel> looks as below
CRM root Web.config

CRM root Web.config

  • Asynchronous Plug-in
    • Since async plug-ins host on “CRM Async Service”, place the configuration details in “CrmAsyncService.exe.config” file
    • Open the “CrmAsyncService.exe.config” file from path “C:\Program Files\Microsoft Dynamics CRM\Server\bin\CrmAsyncService.exe.config
    • Add <System.ServiceModel> node and place the client binding configuration
    • After placing the configuration, the <System.ServiceModel> looks as below
CrmAsyncService.exe.config file

CrmAsyncService.exe.config file

🙂

 

Database ‘Org_MSCRM’ cannot be started in this edition of SQL Server because it contains a partition function ‘AuditPFN’ – Error while restoring organization

June 16, 2012 1 comment

Hi,

I got below error, when I was trying to restore an organization database from SQL server enterprise edition to SQL server developer / Data center editions

Database ‘Org_MSCRM’ cannot be started in this edition of SQL Server because it contains a partition function ‘AuditPFN’. Only Enterprise edition of SQL Server supports partitioning.

Reason :-

  • When CRM 2011 is installed using a SQL Server Enterprise edition, a partition is automaticallycreated for the auditing functionality of CRM 2011.
  • The AuditBase table then uses partitioning (which is only available for SQL Server Enterprise).

Fix :-

  • Either upgrade current SQL version to Enterprise
  • OR
  • We have to run the script to recreate all the indexes on the Primary partition and then drops the partition
  • Refer below MSDN KB article

http://support.microsoft.com/kb/2567984

Below is the useful article on the same

Link

🙂

Rename out of the box associated view ribbon buttons in CRM 2011

Hi,

When we have relationship between two entities, the child entity link add to the left navigation of parent.

For example,

  • “Contacts” link add to the left navigation of “Accounts”
Contacts Associated View In Account

Contacts Associated View In Account

The view we call it as “Associate View” and it contains buttons with below naming convention

  • “Add {Display name of child}” (i.e., “Add Contact” in above screen)
  • “Add Existing {Display name of child}” (i.e., “Add Existing Contact” in above screen)

To rename the “Add & Add existing” buttons below are the steps

  • Create a new solution
  • Add child entity (i.e., Contact) in above example
  • Export & Save solution in local folder
  • Extract folder and open “Customizations.XML” in Visual Studio
  • Find <RibbonDiffXml><CustomActions> node
  • Add below XML

          <CustomAction Id=”Mscrm.SubGrid.{Entity Name}.AddNewStandard.CustomAction” Location=”Mscrm.SubGrid.{Entity Name}.AddNewStandard” Sequence=”210″>

<CommandUIDefinition>

<!–New Button Id – AddNewStandard; Existing Button Id – AddExistingStandard–>

<Button Id=”Mscrm.SubGrid.{Entity Name}.AddNewStandard

Command=”Mscrm.AddNewRecordFromSubGridStandard”

Sequence=”20″

LabelText=”My Custom Text

Alt=”My Custom Text

Image16by16=”/_imgs/ribbon/NewRecord_16.png” Image32by32=”/_imgs/ribbon/newrecord32.png”

TemplateAlias=”o1″ ToolTipTitle=”Add New Contact”

ToolTipDescription=”$Resources(EntityDisplayName):Mscrm_SubGrid_EntityLogicalName_MainTab_Management_AddNewStandard_ToolTipDescription” />

</CommandUIDefinition>

</CustomAction>

  • Save, zip & Export solution

🙂

 

Deleting notes attachments using jscript in CRM 2011

Hi,

In CRM, we can add files as attachments to the Notes.

Notes with attachment

Notes with attachment

  • All the notes get saved in to “Annotation” entity in the data base.
  • The attachment information get saved in to below columns of “Annotation” entity
    • Document Body
    • File Name
    • File Size
    • Is Document
Notes with attachments - Data base columns

Notes with attachments – Data base columns

Deleting attachments using  script:-

To delete the attachment using jscript,

  • Update the “Document Body,File Name,File Size” fields to null
  • And “IsDocument = false” using OData as below

function deleteAttachments(){

var notesId = {GUID of notes};

var objNotes = new Object();

objNotes.DocumentBody = null;

objNotes.FileName = null;

objNotes.FileSize = null;

objNotes.IsDocument = false;

updateRecord(notesId, objNotes, “AnnotationSet”);

}

function updateRecord(id, entityObject, odataSetName) {

var jsonEntity = window.JSON.stringify(entityObject);

var serverUrl = Xrm.Page.context.getServerUrl();

var ODATA_ENDPOINT = “/XRMServices/2011/OrganizationData.svc”;

var updateRecordReq = new XMLHttpRequest();

var ODataPath = serverUrl + ODATA_ENDPOINT;

updateRecordReq.open(‘POST’, ODataPath + “/” + odataSetName + “(guid'” + id + “‘)”, false);

updateRecordReq.setRequestHeader(“Accept”, “application/json”);

updateRecordReq.setRequestHeader(“Content-Type”, “application/json; charset=utf-8”);

updateRecordReq.setRequestHeader(“X-HTTP-Method”, “MERGE”);

updateRecordReq.send(jsonEntity);

}

🙂

 

The maximum array length quota has been exceeded – Error in WCF service

June 9, 2012 1 comment

Hi,

I was getting below exception when I call a WCF service from my plug – in

There was an error deserializing the object of type XYZ. The maximum array length quota (16384) has been exceeded while reading XML data

Below was my requirement,

  • I have to send emails with attachments from my plugin
  • So I built a custom WCF Email service
  • From the plug-in we are calling service method by passing object

I have no clue about the error, because I already given maximum reader quote values in my service configuration (Refer below)

Service Configuration:- 

Binding:-

<basicHttpBinding>

<binding name=”basicHttp_EmailService” openTimeout=”00:30:00″

receiveTimeout=”00:30:00″ sendTimeout=”00:30:00″ maxBufferSize=”2147483647″

maxBufferPoolSize=”2147483647″ maxReceivedMessageSize=”2147483647″>

<readerQuotas

maxDepth=”2147483647” maxStringContentLength=”2147483647

maxArrayLength=”2147483647” maxBytesPerRead=”2147483647

maxNameTableCharCount=”2147483647

/>

Service

<service name=”EmailService“>

After spending couple of hard hours I found the reason & fix for the issue

Reason:-

  • My service is simply ignoring my binding “basicHttp_EmailService” and it’s always taking default binding
  • Reason is
    • My configuration service name does not match with service name in Service Host
    • The name I given is “EmailService” where it has to be “XYZ. EmailService”

Fix :-

  • Right click your “.svc” file and choose “View Markup”
  • Copy the Service name and paste it in your service name
WCF Service Host

WCF Service Host

  • Now my Service configuration looks below

<service name=”XYZ.EmailService“>

🙂

“Query execution time exceeded the threshold” error in Plugins

Hi,

In one of my requirement I was accessing SSRS service API from my plugin to render and read the report

When the plugin execute the code, I was neither getting the expected result nor any error.

To troubleshoot the problem I open the event viewer and I got a warning stating below

Query execution time of 30.1 seconds exceeded the threshold of 10 seconds. Thread: 30; Database: orgname_MSCRM

Reason :- 

  • My plugin registered on Post Update of Account
  • In my plugin, I was rendering and reading a report which has dataset with “Select * From Account”
  • So the problem is with DB lock
    • On update of ‘Account’, a lock establish
    • In the Plugin code, when I try to render report it tries to execute “Select” statement on “Account” we get the above error

Fix :-

  • I modified my Select statement in report dataset with “No Lock” statement

             i.e., Select * From Account (nolock)

🙂