Posts

Showing posts from 2009

Modal Window redraws itself on postback

This is a known issue with IE 7/8, that a window opened using window.showModalDialog redraws itself upon postback. The solution to this problem is that the following statement be added to the <head> tag of the page: <base target = "_self" /> This should do the trick.

Error message when you try to log on to the Microsoft Dynamics CRM Web site from the Microsoft Dynamics CRM 4.0 server: "Request IP Address has differ

Recently on a IFD deployment, i faced this issue "Request IP Address has different address family from network address". I got to know from ( here ) that this is a knows issue. When you try to log on to the Microsoft Dynamics CRM Web site from the Microsoft Dynamics CRM 4.0 server, you receive the following error message: Request IP Address has different address family from network address. This problem occurs if the following conditions are true: 1. You run Microsoft Dynamics CRM 4.0 on a Windows Server 2008-based computer. 2. You use Internet-Facing Deployment (IFD) for Microsoft Dynamics CRM 4.0. The fix for this is simple as posted here . Open your hosts files ( :\windows\system32\drivers\etc\hosts) and add a line for your server name there with an IPv4 address. Reset IIS and this is it. This solves the problem. :) I hope this helps!!

Unauthorized 401 status error after deploying custom web application

Very recently while working on custom solution deployment on ms crm 4.0, i encountered a 401 Unauthorized error. The web site was deployed to work On-Premise and was deployed as a new virtual directory within the ISV folder, authentication was set to integrated windows authentication. I recieved the following error though the login credentials used were correct. Server Error in '/ISV/CustomApplication' Application. The request failed with HTTP status 401: Unauthorized. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Net.WebException: The request failed with HTTP status 401: Unauthorized.Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. St

Custom message on the web page during server side processing

Recently, while working on MS CRM based solution, I encountered a typical aspx page loading issue. I had added a button in ISV config of my custom entity, which would load an aspx page. There was a code block on the page load which would fetch records from the server and display them on the page. The processing time increased enormously since there were a lot many records to retrieve and hence, the page loaded real slow :(. And while the user kept waiting for the page to show up, there was really no intimation to the user that the page processing is going on and the page would finally appear :) I found a very simple solution to this problem through Meta tag usage on the page. Below is a quick sample showing a custom message on the web page while some processing happens at the server side. Though there were other approaches also for this problem, I found this the simplest and easiest to implement. Follow the below mentioned steps to use the Meta refresh tag. 1. Add the Meta refresh Tag

Customizing Workplace

We might be faced with a customer requirement, where it is required that we customize workplace to show say, Type as "Phone Call" instead of "All" and Due as "Today" instead of "All". This customization is possible, although it is unsupported by Microsoft. The activities page displayed as default view in Workplace can be found at: <install dir>\CRMWeb\Workplace\ Modifying the code as follows does the trick: function window.onload() { // ---------- Add the following code to the OOTB method ---------- // Eg. Set Due = Today as default crmDateSelector.selectedIndex = 1; // Eg. Type = Phone Call as default crmTypeSelector.selectedIndex = 3; // --------------------------------------------------------------- } Please note that above code is unsupported.

Tool to enhance Developer Productivity - XRMLinq

It is designed to increase Developer productivity by reducing the amount of time and effort needed to effectively use Dynamics CRM. Instead of learning the ins and outs of the complex Software Development Kit (SDK) and the complexities of CRM you can use this library, putting CRM into a context that you are already familiar with. Example: CRM SDK QueryExpression q = new QueryExpression(); q.EntityName = "account"; q.ColumnSet = new AllColumns(); q.Criteria = new FilterExpression(); q.Criteria.FilterOperator = LogicalOperator.And; q.Criteria.AddCondition("name", ConditionOperator.Like, "A%"); q.AddOrder("name", OrderType.Ascending); BusinessEntityCollection r = sdk.RetrieveMultiple(q); foreach (account account in r.BusinessEntities) { Console.WriteLine(account.name); } XrmLinq CrmDataContext context = new CrmDataContext(sdk); var accounts = (from a in context.Accounts where a.Name.StartsWith("A") orderby a.Name select a).ToList(); foreac

Customization Best Practices

Just came across this list of custmization best practices to follow in the CRM SDK 4.0.10. Using Custom Entities and Attributes ISV solutions can save data by using: • Custom attributes on existing entities • Custom entities • A separate database • Use entity rename to make system entities more meaningful You should use a unique prefix for custom entities and attributes. For example, use an abbreviation of your company name to avoid conflicts with other ISV add-ins. Using Isv.Config.xml Microsoft Dynamics CRM ships with a sample configuration file in the wwwroot_Resources folder. To prepare for installation of ISV add-ins you should rename this file and then create your own configuration file. By doing this you will not confuse the sample UI changes with the UI changes you need for your customization. ISVs should merge changes into the existing ISV.Config file and not overlay the existing configuration file. When Do I Add vs. When Do I Customize an Entity? You should customize a system

The key specified to compute a hash value is expired, only active keys are valid.

Ever accessed Microsoft Dynamics CRM and got the error “The key specified to compute a hash value is expired, only active keys are valid.” The error logged in the trace is as follows: MSCRM Error Report: -------------------------------------------------------------------------------------------------------- Error: Exception of type 'System.Web.HttpUnhandledException' was thrown. Error Number: 0x8004A106 Error Message: The key specified to compute a hash value is expired, only active keys are valid. Expired Key : CrmKey(Id:d0879dd3-7f9d-de11-a5c4-0003ff392bd3, ScaleGroupId:00000000-0000-0000-0000-000000000000, KeyType:CrmWRPCTokenKey, Expired:True, ValidOn:09/09/2009 20:32:01, ExpiresOn:10/12/2009 20:31:55, CreatedOn:09/09/2009 20:32:01, CreatedBy:NT AUTHORITY\NETWORK SERVICE. Error Details: The key specified to compute a hash value is expired, only active keys are valid. Expired Key : CrmKey(Id:d0879dd3-7f9d-de11-a5c4-0003ff392bd3, ScaleGroupId:00000000-0000-0000-0000-000000000

Unable to publish workflows

After installing Rollup 7 on my MS CRM server, I could not publish any of the workflows. The error in the trace files read “Type System.Globalization.CultureInfo is not marked as authorized in the application configuration file.” Add the following entries to Microsoft Dynamics CRM web config did the trick to make it work&#61514; <authorizedType Assembly="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Namespace="System" TypeName="Void" Authorized="True"/> <authorizedType Assembly="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Namespace="System.Reflection" TypeName="AssemblyFileVersionAttribute" Authorized="True"/> <authorizedType Assembly="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Namespace="System.Reflection" TypeName="AssemblyVersionAttribute" Authorized="Tru

Field-Level Security in Microsoft Dynamics CRM

Recently I came across the blog article Field-Level Security in Microsoft Dynamics CRM : Options and Constraints (at http://blogs.msdn.com/crm/archive/2009/11/16/field-level-security-in-microsoft-dynamics-crm-options-and-constraints.aspx ) which talks about restricting attribute level access to certain users based on the different access channels for users to Microsoft Dynamics CRM. On the client side, one of these ways can be used – a. Passing an indicator to the field to display to the user that they user cannot view the attribute e.g. ‘******’, ‘Restricted’, ‘Not Authorized’. b. Making fields read only or hidden if a user is not authorized to view them. Server Side Restriction –Two strategies are basically proposed: 1. Role based filtering - If the user does not have a role that is entitled to access the attribute then it will be restricted. An advantage of role based filtering (and a reason for its simplicity) is that the access to an entity’s attributes can be defined without need

JavaScript code to parse FetchXMLResult

Recently I came across a scenario, where I was required to query based on an intersect table for which Fetch method can only be used, which required parsing Fetch XML Result string was at the client side. Fetch method is the query language used in Microsoft Dynamics CRM. It is based on a schema that describes the capabilities of the language. The FetchXML language supports similar query capabilities as query expression. Following is the code that can be used to achieve the same: var resultXml = xmlHttpRequest.responseXML; var objNodeList = resultXml.documentElement.selectNodes("//FetchXmlResult"); var totalNodesCount = objNodeList.length; if (totalNodesCount > 0) { var iter = 0; var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.loadXML(objNodeList[0].childNodes[0].nodeValue); var objResultList = xmlDoc.documentElement.selectNodes("//result"); for(iter = 0; iter <= totalNodesCount; iter++) { // Columns Retrieved can be accessed using child no

msftesql and cisvc services error in MS CRM 4.0

While installing MSCRM 4.0 on Windows Server 2008, having SQL Server 2008 preinstalled, the installation verification fails and displays missing components msftesql and cisvc services. 1) msftesql (the sql server full text indexing service) has a different name against sql server 2008. Just rename the registry key HKLM\System\CurrentControlSet\Services\MSSQLFDLauncher to msftesql to give an illusion to the MSCRM verification phase that services is present in the system so that it does not fail while installation. Now restart the system and run the installation of MSCRM again. After installation rename the HKLM\System\CurrentControlSet\Services\msftesql back to MSSQLFDLauncher. 2) To solve the cisvc services error, right click the MyComputer->Manage, now right click the Roles ->Add Roles and now install the file services role.

Using Disposable Windows SharePoint Services Objects

During my last project on MS CRM 4.0, I had to integrate SharePoint and MSCRM. This majorly involved creation of a web part for data analysis. During the development, I encountered scenarios facing long term retention of share point objects in memory. Memory leak is one of the major problems that can arise due to bad coding practices. Disposing the used SharePoint Objects is one of the best practices while coding in SharePoint. Here, I have explained why, how and when to dispose off the SP Objects in code. The objects in the Windows SharePoint Services 3.0 object model serve as an interface for working with Windows SharePoint Services data. The developers frequently call into the object model to read data from or write new data to the Windows SharePoint Services store. The Windows SharePoint Services object model contains objects that implement the IDisposable interface. One must take precautions when using these objects to avoid their long-term retention in memory in the Microsoft .

Issues after Re-Naming MS CRM Servers computer/machine name

Currently I faced a scenario where the machine on which MS CRM 4.0 was installed was required to be renamed on LAN. My deployment had the SQL Server installed on another machine on LAN. After changing the MSCRM Server machine name, MS CRM browser stopped working and started showing error “SqlException: Login failed for user [Domain Name]\[New Machine Name] .” This error comes when the MS CRM server related entries in registry and database (that refer to the server name) have not yet been changed to the new server name This problem could be solved by 'Repairing’ the MS CRM 4.0 installation on the machine after renaming it. Go to the Control Panel -> Add or Remove programs-> Microsoft Dynamics CRM Server. Repair the installation. Repair installation internally performs the following actions: a. In the registry, ServerURL key value at HKEY_LOCAL_MACHINE/SOFTWARE/MICROSOFT/MSCRM is updated with the new machine name (example: the value would be like “http:// :5555/MSCRMServices”

Working with MSCRM 4.0 Reports in IFD deployment

Recently for a project requirement I had to deploy MSCRM 4.0 on an IFD server. Everything else seems to work properly except the Reports. The reports were running good on on-premise configurations for the same organization. This issue was same for Custom reports as well as the out-of-box reports by MS CRM. Its then I read that this is a common issue with IFD deployment. To resolve this, the deployment must be running the Microsoft Dynamics CRM Connector for Microsoft SQL Server Reporting Services . The SRSDataConnector for MS CRM 4.0 comes with the installation files for MS CRM 4.0 and is located on the installation CD: “ drive:\Server\i386 \srsDataConnector ” folder. Run the “ setupsrsdataconnector.exe ” executable in the mentioned folder and you are done with it! How does it work? - When a Microsoft Dynamics CRM report is run, Microsoft SQL Server Reporting Services Viewer requests the report and data from the remote Microsoft SQL Server Reporting Services computer. To access the re

Initializing distinct XAMLs included in a single XAP

So I had a situation where I had to load multiple charts on my custom page default.aspx within Microsoft Dynamics CRM. These charts rendered different reporting data after fetching it using the MS CRM webservices. I used silverlight visifire charts for each of my reports. Instead of creating a different silverlight application for each of my reports, I instead created different XAMLs for each of them and compiled a single XAP. Well, this is a well tried and tested approach used in any silverlight application or any aspx application using Silverlight controls which involves multiple XAMLs compiled in a single XAP. These are the steps I used: 1. Created a Silverlight application that contained multiple XAMLs each one including a different report (i.e. a different visifire chart) and compiled it as one "SLDashboardPOC.xap". 2. For each of the reports to be rendered, I embedded the compiled Silverlight XAP control multiple times in my default.aspx as follows: <asp:ScriptManage

Windows Prompt for an IFD Deployment

This blog will explain why Microsoft Dynamics CRM prompts for Windows Credentials when you log on to your development environment (configured for IFD ) using the server's IP address or the Host file configured URL (such as http://contoso.crm.grapecity.org). This is basically determined by MS CRM by reading the registry value of the key [HKEY_LOCAL_MACHINESOFTWAREMicrosoftMSCRM]- IfdInternalNetworkAddress. In reality, Microsoft Dynamics CRM will look at the IP address of the incoming request and match it against the internal range of the registry key specified. If the request is in the internal range of the registry key, it will give you a "Windows experience." If the IP address is external, it gives an "IFD experience." This registry can be modified to switch between the windows and the IFD experiences (and this is supported :)). You will need to set the value for the "IfdInternalNetworkAddress" registry key in order to change the internal subnet of th

Using CRM Services to create or update records in large numbers

Recently, I implemented a plug in code which invoked auto creation of records from a contacts list (rather marketing lists based on MS CRM contacts) for my custom entity. The code worked well but it hanged whenever I considered a marketing list of more than 3000 contacts. The error logged read: Only one usage of each socket address (protocol/network address/port) is normally permitted. Basically, the error was thrown when the creation process exhausted the limit of socket connections allowed by the IIS and the SDK still polled for another connection and consequentially timed out after a certain number of records were created. A quick workaround for this is to change the following entries in the registry: HKLM\System\CurrentControlSet\Services\Tcpip\Parameters\MaxUserPort to 65534AndHKLM\System\CurrentControlSet\Services\Tcpip\Parameters\TCPTimedWaitDelay to be 30 The link : http://dmcrm.blogspot.com/2008/07/updating-records-in-mass-via-sdk.html also mentions a resolution of this by us

IFD Implementation for custom web pages and Anonymous Access

When deploying my custom web pages for an IFD deployment, I got a FileLoadException (Exception from HRESULT: 0x80131401) on accessing the page in the browser. Basically, this issue arose since anonymous access was somehow disabled for the “ISV/CustomPages” application in IIS while by default it is enabled for the Microsoft Dynamics CRM website. This implied that my custom web site was using Windows NT Authentication, while the Microsoft Dynamics CRM Website was enabled for anonymous access. Hence, I got “Loading this assembly would produce a different grant set from other instances” on accessing any of my web pages from within MS CRM. Simply turning on anonymous access for my custom website did the trick and rendered all my custom web pages correctly :)

Support for onPremise version over internet

Recently we faced issue when we tried to access MSCRM in MS Outlook. We were trying to access onPremise version over Internet and was getting Authentication failed error while configuring using Configuration Wizard. After lot of research to resolve authentication problem, we did found out that only IFD version can be accessed in MS Outlook. OnPremise version cannot be accessed in Outlook over internet. However, onPremise version can be accessed in Internet explorer, but it might not be supported. It is recommended to use IFD version (Service Provider edition), if you have to use MSCRM over internet. OnPremise edition should be used inside corporate network only.

Resolving “Cannot Create File Mapping” on custom webpage

When I deployed my custom webpage on Windows Server 2008 (64 bit), and accessed it I got an InvalidOperationException with the description “Cannot create file mapping error “. The Microsoft CRM Trace read as follows: Exception information: Exception type: TypeInitializationException Exception message: The type initializer for 'Microsoft.Crm.Authentication.BaseAuthenticationProvider' threw an exception. [2009-05-11 22:42:33.5] Process: w3wp Organization:00000000-0000-0000-0000-000000000000 Thread: 3 Category: Exception User: 00000000-0000-0000-0000-000000000000 Level: Error CrmPerformanceCounterFactory.LoadCounters at CrmPerformanceCounterFactory.LoadCounters(PerformanceCounterLoadSetting settings, String component) at BaseAuthenticationProvider..ctor() at MultipleOrganizationSoapHeaderAuthenticationProvider..ctor() at RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNee

Combining OR and AND Conditions in Query Filters

Consider a scenario where you have to run a query to retrieve records from MS CRM with the following conditions: Select Attribute1, Attribute2, Attribute3 from Entity_A where (Attribute1=value1 OR Attribute1=value2) AND Attribute 2=value3 AND Attribute3=value4 Since, FilterOperators permit only AND or OR Conditionoperators, you can use the FilterExpression.filters property to use a nested subquery for the OR clause. The code for this will be as follows: try { ColumnSet cols = new ColumnSet(); cols.Attributes = new string[] { Attribute1, Attribute2, Attribute3 }; ConditionExpression attr1Val1= new ConditionExpression(); attr1Val1.AttributeName =Attribute1; attr1Val1.Operator = ConditionOperator.Equal; attr1Val1.Values = new object[] { value1}; ConditionExpression attr1Val2= new ConditionExpression(); attr1Val2.AttributeName = Attribute1; attr1Val2.Operator = ConditionOperator.Equal; attr1Val1.Values = new object[] { value2}; FilterExpression attr1Conditions= new FilterExpression(); attr

Updating Retrieved Custom Entity Records

The update procedure for Dynamic Entities works well for updating custom entities. However, consider a scenario where you retrieve typecasted records of a custom entity meeting a certain criteria. If you wish to update certain information in these records, using DynamicEntity will throw a type cast error (as the service.retrieve function will return you not a DynamicEntity type but a custom entity type, since the entity for the query is specified by you). The resolution for this is to use the TargetUpdateCustomEntity class for the update. For example, if you wish to retrieve “prospects” in the city “Redmond” and associate them with a certain “project”, you can use “TargetUpdateProspectsRequest” for the operation. ColumnSet cols = new ColumnSet(); // Sets the ColumnSet's Properties cols.Attributes = new string[] { "projectid" }; // Create the ConditionExpression ConditionExpression condition = new ConditionExpression(); // Set the Condition for the Retrieval to get the P

Passing Parameters to a URL Using SiteMap for a Multilingual solution

In order to host a web page in the MS CRM sitemap, where the virtual directory resides on the IIS (or specifically in the MS CRM Directory, as is the case with an ISV solution), you are required to export the sitemap, add a SubArea element to the sitemap xml, and then re-import the edited file. In case it’s a single language solution, you can specify the URL as http://myserver/mypage.aspx?orgname=AdventureWorksCycle&userlcid=1033&orglcid=1033 However, if your solution supports more than one languages for the user, you will need to get the userlcid parameter on the page in order to render it based on the user’s currently set language (you cannot simply set it to “userlcid=1033”). Setting the PassParams parameter to 1 in the SubArea tag does this: <SubArea Id="MyCustomArea" Icon="/_imgs/Icon.gif" PassParams="1" Url="/../ISV/MyCustomSite /HomePage.aspx" Client="Web"> You can then use the page’s querystring in order to read

How to develop yahoo widgets for accessing MSCRM 4.0 data: Part 2

This blog is in continuation to my last blog How to develop yahoo widgets for accessing MSCRM 4.0 data in which I had taken you through the development of yahoo widgets for accessing MSCRM 4.0 data for the on-premise deployment of MSCRM 4.0. Now, I’ll explain how you can access MSCRM 4.0 data in the internet facing deployment (IFD) model of MSCRM 4.0. Well, the first and foremost difference between the On-premise & IFD models is the strategy used for authentication, while fetching data from CRM using the web services . In order to authenticate the web service calls in the hosted (IFD) model we need to specify the valid active directory user credentials to request for the issue of Crm Ticket . This Crm ticket will inherently be used in the crm authentication token provided to the soap request for authenticating the web service calls to fetch data from MSCRM. See the JavaScript below to retrieve the crm ticket. Fire a soap request including valid user credentials and on authenticati

Bulk Edit Issue on Custom Entities

A typical problem while performing a Bulk edit on any custom entity is that all the hidden fields on the form become visible. Since MS CRM does not provide a way out to let the fields remain hidden on bulk edit form, you might think of restricting users from performing bulk edits for custom entities. Here is the simple way to proceed on this: 1. On the custom entity Form , add a hidden Iframe . 2. Create a simple . htm file and create a new virtual directory in IIS under the ISV folder where you place this htm page. 3. Specify this relative path as the URL of the iframe. Example if your custom application is hosted at \ISV\MyCustomWebPages folder and the . htm file is MyPage.htm , the Iframe URL would be \ISV\MyCustomWebPages\MyPage.htm . In the . htm file, check the form type for Bulk Edit. MSCRM by default provides form type an enum for form types. (See SDK: http://technet.microsoft.com/en-us/library/cc150873.aspx ) Bulk edit type form value is 6. if(parent.document.forms[0]

How to develop yahoo widgets for accessing MSCRM 4.0 data

Image
In this blog, I’ll take you through the development of yahoo widget for accessing MSCRM 4.0 data for the on premise deployment of MSCRM. In my future blogs you may find the implementation for the hosted & Crm Live models as well. The purpose of this article is to quickly access the MSCRM data & provide a quick navigation link to directly jump to the record in MSCRM using browser.So, what kind of data would be more relevant to a user in MSCRM? Well answer to this question depends on the role of the user but, MSCRM Activities are something which is relevant to all types of users. So, in this walkthrough we’ll retrieve the activity records of MSCRM 4.0 to display i.e fetching all the activities for the currently logged in user from the MSCRM server. Audience Profile: The target audience should already be familiar with Yahoo widget’s development and should have little understanding of XML, JavaScript and webservice calls as well. To start with prepare your layout for the widget by

Creating your custom solution for MS CRM 4.0 - Programmatically fetch Isv Config and Sitemap for an organization

The CRM SDK provides ExportXmlRequest in order to export any customizations programatically. For example, the isv config for an organization can be exported as : CrmServiceRef.ExportXmlRequest exportRequest = new CrmServiceRef.ExportXmlRequest(); // Define the nodes to retrieve, the site map and the isv configuration. exportRequest.ParameterXml = @"<importexportxml> <entities></entities> <nodes> <node>isvconfig</node> </nodes> <securityroles></securityroles> <settings></settings> <workflows></workflows>

Troubleshooting the Reports Issues in MS CRM 4.0

This article helps you troubleshoot couple of Reporting Services issues that you may encounter while running reports in MS CRM 4.0.The problems may occur even when the MS CRM 4.0 installation was done successfully and no error message was shown for reporting services. The most common error message that is generally displayed while running the report in MS CRM 4.0 is “ The report cannot be displayed ”. This message is a very general one and does not point to any specific problem. There may be various causes for it and one of those is that SQL Server Reporting Services is not running on the server where SQL is installed. To solve this problem, locate the service in Service Manager and check its status and startup type in the Properties. If the status is ‘Stopped’, first make the startup type of the service as ‘Automatic’; this will ensure auto-start of the service whenever required, and then start the service. If you are not able to start the SQL Server Reporting Services and you get Er