Posts

Showing posts from June, 2009

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