Merry Christmas!

Everybody,

Thanks for reading this blog another year long. Now its time for me to stop working this year. We just won a nice new project, the MS CRM Outlook V3C has just been released and so it is time to start a great holiday. I'll spend a lot of time with my friends, family and above all my wonderfull girlfriend.

I wish you all a very good time around both christmas and new year. I hope you can all enjoy the time with your relatives and hope to see you next year again!

Ronald



Filter data in a CRM lookup field

Curt Spanburgh posted this message on the Sandbox: Custom Lookup Dialog for Microsoft Dynamics CRM 3.

In this post he describes that it is possible to filter the data in a lookup box. He also gives an example which uses data on the form to filter the lookup data. For testing purposes I have used the code below. It should be placed in the form onload of the account entity. It does filter the lookup parent account and will only show accounts which do have a parent account already. Not necessarily useful in a business case, but it does give you a clear example.


crmForm.all.parentaccountid.lookupbrowse = 1;
crmForm.all.parentaccountid.additionalparams = "fetchXml=<fetch mapping='logical'><entity name='account'><all-attributes/><order attribute='name' descending='false'/><filter type='and'><condition attribute='parentaccountid' operator='not-null'/></filter></entity></fetch>";
crmForm.all.parentaccountid.additionalparams += "&selObjects=1&findValue=0";


As you can see, some extra values are sent to the additionalparams attribute. These are selObjects and findValue. The selObjects should be set to the enity id of the lookup its entity.

To help you create fetchXml queries look here: Using Advanced Find for FetchXml

Great tip Curt!

Update: This does not work in CRM 4.0. Instead, look at the add-on as developed by Stunnware: http://www.stunnware.com/Products/FLD4/Default.htm



Developing on multiple VPC's

Hi guys,

I'm wondering what technologies you're using for developing CRM projects. Especially when you have multiple clients..

Personally I use virtual machines via Virtual PC. Each PC is about 10 gb huge though. So I was looking around on the internet and I found a good solution to that. Now this is what I do:

- Create one VPC which has Windows Server 2003, MSSQL, CRM, Sharepoint, Office, Visual Studio etc
- Shutdown that VPC and mark the harddisk file as read only
- Create a new VPC based on that harddisk with a check set at 'Enable undo disk' (and RAM adjusted to something like 1400 mb)
- Modify CRM to meet the customer needs
- Shutdown the VPC by using 'Save State and Save Changes'
- Make sure that 'Commit changes to the virtual harddisk' is UNCHECKED
- Select 'OK'

By doing so, you would only need 1 huge VPC and the rest are small files of about 500 mb till 2 gb. That saves me sooo much space and time! If somebody asks me a question and I dont have crm at hand, then just create a new vpc, start it (that takes a while though), run the test and remove the undo disk. Done!

You can use the Public demo VPC by Microsoft, but keep in mind that there are modifications made to that VPC which you should undo first.

Hope this helps you as well!

Ronald



Set a default entity on a lookup window

In case you have more entities to chose from on a lookup window, then you might want to be able to set the default for this lookup. For instance, the regarding field on an activity entity like letter, email and fax does support multiple entities. If you want this to default set to contact, then use this javascript on the form onload:


//set default
crmForm.all.regardingobjectid.defaulttype = "2";


Even better, what if you dont want your user to be able to choose any entity and force them to use the contact entity? Then use this script:


//set only contact
crmForm.all.regardingobjectid.lookuptypes = "2";

//set icon
crmForm.all.regardingobjectid.lookuptypeIcons = "/_imgs/ico_16_2.gif";


Dont forget to set the icon. The icon will be displayed in front of the selected name after a selection in the lookup box has been made.

For a custom entity, then mind that the icon does not work that easily. Use this script for custom entities:


//set only contact
crmForm.all.regardingobjectid.lookuptypes = "10003";

//set icon
crmForm.all.regardingobjectid.lookuptypeIcons = "/_imgs/icon.aspx?objectTypeCode=10003&iconType=GridIcon&inProduction=1&cache=1";


Good luck!



Maximum amount of records in Excel export

I'm very busy at the moment (just like you all probably), so just a small post. The default for the Excel export is a maximum of 10.000 records. If you need to export more, then you'd need to modify a registery setting. Follow the next steps to achieve this:

- Start Regedit
- Navigate to HKLMachine\Software\Microsoft\MSCRM
- Create a new DWORD value named 'maxrecordsforexporttoexcel'
- Give the new value any value (minimum is 500)

Ronald



Clear BizTalk Messagebox

Since the release of the CRM - BizTalk connector, you're all doing integrations right? Did it happen to you that you start a BizTalk application one evening and in the morning your messagebox is filled with more then 100.000 instances? If that is the case, then you can delete these by using the BizTalk Administration console. Unfortunately this will take hours and hours..

Instead, running this code on the BizTalk databases solves the issue for you:


DELETE FROM BizTalkMsgBoxDb.Instances
GO
DELETE FROM BizTalkMsgBoxDb.InstancesSuspended
GO


Keep in mind that you should only do this on development, test and acceptation, NEVER on production.



Reporting services on another machine

The database server doesn't have to be running on the same server as the CRM application itself. If you follow the installation guide, then everything should work fine. But... Avanade has done this for several clients and sometimes it appears that the reporting might not work. The error message will be:

“An error has occurred. For more information, contact your system administrator”
or
"error 401 – Unauthorized access"

If this is the case in your situation as well, then take a look at the following steps.

First you have to enable Kerberos Authentication for IIS on the CRM Server.
- Open a DOS box and browse to c:\inetpub\adminscripts
- Run the command: cscript adsutil.vbs set w3svc/1/NTAuthenticationProviders "Negotiate,NTLM" (If only one website is running you can use 1 in the commandline. Otherwise you have to check the logfile directory to see what number you should use)
- IISRESET

If your services run with the "network service" account you have to open ADSIEDIT and open the propeties of the CRM server. Go to SPN settings and add the next lines:
(Computername is your CRM server and FQDN is your Fully Qualified Domain Name)

HOST/computername
HOST/computername.FQDN
HTTP/computername
HTTP/computername.FQDN

You have to do a similar action on the SQL Server, the default instance uses port 1433
MSSQLSvc/computername:1433
MSSQLSvc/computername.FQDN:1433

Finally, on the client computer check if in Internet Explorer "Integrated Windows Authentication" is activated (under the advanced settings of the internet options)

Hope this helps you to get reporting to work as well!



Microsoft CRM for Enterprise Organizations

Microsoft started putting Microsoft CRM into the market as an application for Small and Medium sized businesses. This didn't stop us from Avanade and also other partners to use this application in larger and even enterprise businesses. With the release of Microsoft CRM 3.0, the application is really Enterprise ready.

Avanade is the trusted advisor that customers depend on to deliver a successful implementation. Our team of experts has deployed Microsoft’s CRM solutions in the enterprise more than anyone else in the industry. Based on the experiences we have gathered, reports and whitepapers are being published on our websites www.avanade.com and www.avanadeadvisor.com. Here are some interesting articles:

Realizing the Vision of CRM with the Avanade® Federated Architecture
A report which shows the Avanade Federated Architecture. Federated architecture allows companies to deploy more than one instance of CRM, while ensuring that critical data remains in-synch and up-to-date across the entire organization. With synchronization across multiple CRM instances, collaboration is possible across regions and divisions, while individual groups can maintain their independence and optimize operations where necessary.

Avanade Enterprise CRM
At Avanade, we believe CRM is a holistic approach to improving customer acquisition, retention, and profitability. Simply put, it’s connecting the Right Customer, with the Right Information, at the Right Time across the Enterprise. This document describes the Avanade's Enterprise CRM offerings.

Scaling Microsoft® Dynamics™ CRM
Avanade has developed a whitepaper as well and it describes the Scalability and Performance Testing and Tuning Results for the enterprise.This white paper summarizes the scaling characteristics of Microsoft Dynamics CRM 3.0 with a medium to heavy sales force automation transaction load supporting 3,000 concurrent users. Avanade initiated performance testing in 2006 at our technology infrastructure lab in Seattle, Washington.

Our public references include:
- O.C. Tanner
- ABN Amro
- BGE Home
- Sara Lee
- Bouwfonds

If you'd like more information on how Avanade can leverage CRM in Enterprise organizations, feel free to contact me or Anthone Withers, Avanade global CRM Solutions Director, at mbs@avanade.com.



Using the Advanced Find for FetchXML builder

Some time ago I talked about the program "FetchXML builder" to build FetchXML queries: http://ronaldlemmen.blogspot.com/2006/09/fetchxml-builder.html, but take a look at the next solution.

You can just open the Advanced find page and build the query as you like. Then run the query to see if it returns the data as you wish it should. If you are satisfied with the results and you want to know what query was sent into the CRM Framework, then press F11 to get the address bar and enter this script and press enter.


javascript:alert(resultRender.FetchXml.value);

If you get a warning about leaving the page, just press 'ok' and then the query which is sent to the framework opens up in a popup. Unfortunately you cannot select the text to copy and paste. But with Windows XP and Windows Server 2003 you can copy all text on the popup by clicking somewhere on the popup (not on the button "OK" ofcourse) and pressing ctrl+c. Now in notepad you can paste the text of the FetchXML.

Good luck!

Update: Thanks to Piotr in the comment section I have learned the javascript prompt command. Try this instead of the alert:

javascript:prompt("my query:", resultRender.FetchXml.value);



Error: Deletion Service failed to clean up some tables

Some people have been experiencing the following error message in the event log:

Event Type: Error
Event Source: MSCRMDeletionService
Event Category: None
Event ID: 16387
Date: Date
Time: Time
AM User: N/A
Computer: Computer_Name
Description:
Error: Deletion Service failed to clean up some tables.

Microsoft has a solution for this message. See http://support.microsoft.com/kb/921391/EN-US/ for their solution.

Personally I don't feel comfortable with the solution they give. They are removing the enforced relationships for the tables which cause the issue. This will leave you with orphaned records in your database and probably the same issue when you upgrade to the upcoming titan release. Here are my steps to correctly fix this issue (partly copied from the MS solution) :

To identify the table where the Deletion Service is failing, follow these steps:
1. On the Microsoft Dynamics CRM server, click Start, click Run, type cmd, and then click OK.
2. At the command prompt, locate the system drive, locate the program files, locate Microsoft Dynamics CRM, locate the server, locate the bin, type crmdeletionservice.exe –runonce, and then press ENTER. You then receive a message that resembles the following message:
Can't clean up the following tables: Campaign

Note The table that is returned in the message is the table for which the Deletion Service failed.

The following example demonstrates how to resolve this problem for the Campaign table.

To resolve the problem for the Campaign table, follow these steps:
1. Run a statement in Microsoft SQL Query Analyzer. To do this, follow these steps:
a. Click Start, point to All Programs, point to Microsoft SQL Server, and then click Query Analyzer.
b. Run the following query against the Organization Name_MSCRM database.
delete from Campaign where DeletionStateCode = 2
This query returns a message that resembles the following message:

DELETE statement conflicted with COLUMN REFERENCE constraint 'campaign_leads'.

2. Run two queries agains the Organization Name_MSCRM database.
delete from [table name in message] where [column name in message] in (select campaignid from Campaign where DeletionStateCode = 2)

delete from Campaign where DeletionStateCode = 2

By doing this, you do delete the associated records as well. Keep in mind that once deleted, you cannot get the data back. Therefore always make a backup first!



MSCRM Mobile Applications

Microsoft does offer 2 different applications for the mobile devices. These are the Microsoft Dynamics CRM 3.0 Mobile client (in short the CRM Mobile client) and the CRM Mobile Express for Microsoft Dynamics CRM 3.0 (Mobile Express client). Next to these two applications there is the CWR Mobility's Mobile CRM client (CWR Mobile client). Now which application to use?

Lets look at the descriptions for each client:

Microsoft Dynamics CRM 3.0 Mobile application
Microsoft CRM Mobile provides salespeople with up-to-date information about their accounts and contacts, and helps them manage sales opportunities and track sales-related activities.

Salespeople select the data to take with them on the road. While disconnected, they can enter data related to their sales activities. Salespeople can synchronize data with the Microsoft CRM server when the network is available, either when the user is on the office network, or when wireless access is available through CDMA or GPRS/Edge. The data entry forms and views can be customized for your business.

CRM Mobile Express for Microsoft Dynamics CRM 3.0
CRM Mobile Express for Microsoft Dynamics CRM 3.0 is a shared-source initiative sponsored by Microsoft that offers a lightweight, mobile browser client for viewing and editing data in Microsoft Dynamics CRM 3.0. Now you can manage important Sales, Service and Marketing information from your Windows Mobile, Smartphone and HTML 4.0 compatible devices! CRM Mobile Express for Microsoft CRM also includes a Microsoft Dynamics CRM 3.0 Administration Console that can be used to customize your mobile data objects - such as adding custom CRM entities to CRM Mobile Express, set data object read and write permissions, and configure mobile forms according to your CRM system's design. This community project comes complete with three documents - an Installation guide, a User guide and a Developer guide, as well as the application source code for both the CRM Mobile Express Client and Administration Console applications. Developers can use Visual Studio.net 2005 to extend and modify both applications as they see fit.

CWR Mobile CRM by CWR Mobility
CWR Mobile CRM delivers:
- Access to Dynamics CRM 3.0 while out of the office – allowing for up-to-the-minute data changes (from the field and the office) and instant access to current data.
- A user-friendly interface on the Windows Mobile devices for intuitive CRM data access and entry by the mobile professional. Both while the device is connected online to a wireless service provider and offline, such as in an airplane, or deep inside a customer’s warehouse

Using CWR Mobility's Mobile CRM, sales and service teams have instant access to important customer information when and where they need it.

Differences
There are some factors which would influence the result on which application to use. These factors include:
- Out of the box functionality
- Extensibility
- Offline support
- Client Requirements
- Language support
- Price

Out of the box functionality
When comparing the functionality out of the box, then the CWR Mobile client gets the highest score. It supports all (custom) entities, (custom) attributes, a very efficient synchronisation mechanism, field level security via configuration and a lot of minor, but useful features like: direct calling the phonenumber on the screen and TomTom integration.

The Mobile Express client misses the paging functionality out of the box.

Extensibility
Both the Mobile Express client as well as the CWR Mobile client have good possibilities for extensions. The Mobile Express client is a shared source initiative which offers all the code which can be extended. The CWR application supports the addition of custom build controls and client side business logic. Of course these extensions should be developed by professional developers.

Offline support
The CWR Mobile client support Online as well as Offline modes (network aware). The CRM Mobile client supports only Offline mode with a manual sync. The Mobile Express client only supports Online mode.

Client requirements
The Mobile Express client only requires a HTML 4.0 compatible device. If Blackbarry support is required, then this is the only supported application.

The CRM Mobile client as well as the CWR Mobile client requires Windows Mobile or PocketPC. The CWR Mobile client requires a screen resolution of 240x240 and 48mb ram. The CRM Mobile client requires a screen resolution of 240x320 and 64mb ram.

Language support
The CWR Mobile application supports all supported Microsoft CRM languages. They also allow more languages to be added if required. The Mobile Express client supports all CRM languages and the CRM Mobile Client supports only the languages English, German, French and Spanisch.

Price
The price depends on the cost of the product and the additional costs for customization by a partner. Here are listed the prices of the product. Prices of customization are variable.

The CRM Mobile client as well as the Mobile Express client are available for free. The current list price of the CWR Mobile client is €299 per mobile user.

Overall conclusion
By using a mobile application for MS CRM, you will be able to increase your sales. You are able to react very quickly to questions you get from customers and you can check the latest information just before you enter the clients room.

In the part above I have shown my experiences with these applications. In my point of view, the CWR Mobile application deliveres the best functionality. It supports everything that I expect a mobile application should support: network aware data access (online and offline), all languages, entities, custom entities and integration with many other applications on the client device. The price of the product is very reasonable and the quality you'll get for it is very good.

More Information
Microsoft Dynamics CRM 3.0 Mobile:
http://www.microsoft.com/downloads/details.aspx?FamilyID=ea5a3566-7ec8-4afe-bbfa-91e7210c55c4&DisplayLang=en

CRM Mobile Express for Microsoft Dynamics CRM 3.0:
http://www.gotdotnet.com/codegallery/codegallery.aspx?id=8e65fc13-4073-406c-879c-442faf78f2c8

CWR Mobility's Mobile CRM: http://www.cwrmobility.com/Products/CWRMobilitysCRM30Mobile/tabid/73/Default.aspx



Enable or disable advanced find feature on attributes

Did you know that you can set each attribute of each entity to be able for advanced find or not?

By doing this you can specify which fields the users can search on. That means that all the fields which you do not use in your CRM system can be removed from the list to make using the advanced find easier.

So how do you do this? Just:
- go to system
- customizations
- customize entities
- select any entity
- go to the tab attributes
- select any attribute
- swich the flag 'Searchable'

Hm? You dont have that flag? Go get it at: http://support.microsoft.com/kb/912061/EN-US/

Good luck!



Accessing webservices via Javascript (aka AJAX)

Several times I've been asked, or saw the question on the newsgroups, how to create a piece of javascript code which retrieves data from a webservice. This information has been included in the SDK and you'll be able to find it here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/CrmSdk3_0/htm/v3d0accessingwebservices.asp

Here's the code example of that page:


// Declare variables.
var i=0; var j=0; var k=0; var r=0;
var serverUrl = "http://www.webservicex.net";

// This is the picklist.
switch (parseInt(event.srcElement.DataValue, 10))
{
case 1:
i = "JPY";
break;
case 2:
i = "GBP";
break;
case 3:
i = "EUR";
break;
}

// Instantiate at connection to the Web service and call the get method.
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

xmlhttp.open("get", serverUrl + "/CurrencyConvertor.asmx/ConversionRate?FromCurrency=USD&ToCurrency="+escape(i), false);
xmlhttp.send();
var startTag = "<double xmlns=\"http://www.webserviceX.NET/\">";
var endTag = "</double>";
var exch;
var valueStart = 0;
var valueEnd = 0;

// Parse the returned XML string.
valueStart = xmlhttp.responseXML.xml.indexOf(startTag, valueEnd) + startTag.length;

valueEnd = xmlhttp.responseXml.xml.indexOf(endTag, valueEnd+1);
exch = xmlhttp.responseXML.xml.substring(valueStart, valueEnd);

// Set the Exchange rate on the custom attribute.
crmForm.all.fabrikam_exchangerate.DataValue = parseFloat (exch);
j = crmForm.all.totalamount.DataValue;
var kk = j*(parseFloat(exch));

// Calculate and set the total sum in the selected currency.
crmForm.all.fabrikam_totalcurrency.DataValue = kk;



Clone your production system: VMware Converter 3.0

Imagine you have a problem on your production server. You try to reproduce the error on your dev, test and acceptance servers and they all work fine... Now what? How do you solve this? I really don't like to debug errors on the production machine..

VMware has the solution! They have created a free Physical to Virtual Convertion tool which does not require your server to go offline! They're currently in beta test, but will release within approximately 6 months with the final version.

What Is VMware Converter?
VMware Converter is a highly robust and scalable enterprise-class migration tool that reduces the time that IT managers spend converting physical machines to VMware virtual machines. Using a snapshot based cloning mechanism that is extremely fast and reliable, VMware Converter enables remote conversions without disrupting the source server during the conversion process.

For more information:
http://www.vmware.com/products/beta/converter/

If you can't wait until this product has been released, then you can work with VSMT, but you do need deep knowledge of AD, DNS etc.

The tool VSMT is developed by Microsoft and it works with Virtual Server and ADS. See this url for more information:
http://www.microsoft.com/windowsserversystem/virtualserver/evaluation/vsmt.mspx



BizTalk Adapter available for download!

It's been some time waiting since the announcement at the Convergence in Texas for the BizTalk Adapter to be released, but it has gone public! Here are links to the adapter and a code sample:
The adapter
Code Sample

This BizTalk connector basically exposes all the CRM API's in BizTalk. For each entity schemas can be generated. The adapter can perform Create, Update, Delete or Execute actions based on the input.

I've been using the beta of this adapter for creating integrations with several other systems. Some integrations I have been working on already:
- Lead entry via email: POP3, BizTalk, MSCRM
- Continuous integration with financial system: Webservice, BizTalk, MSCRM
- Daily bulk import of data: SQL, BizTalk, MSCRM

Drop me a note if you'd like me to post a howto regarding this Adapter.

Have fun integrating CRM!



Determine which priviledges are required

I do assume that you do not provide the end user administrator rights on the crm installation. You probably have defined your own security role with the least priviledges the user should posess. Well how do you know what priviledges the user should posess?

There's an update to the online SDK with this information. You can browse to this url and you'll see a list of messages. Under each message the required priviledges are listed.

Now if you have a question like "Which priviledges are required for adding facilities to a resource group?" can be answered with a visit to that page.



FetchXML Builder

Some time ago Microsoft organized the code contest. Users have been asked to share their greatest assets with the community. One of the winners is James Downey. He has created the FetchXML Builder: a free user-friendly tool for building and testing FetchXML statements.

Today I have been able to use this tool in my development project. It works very intuitive, at least for people having fetchxml knowledge. I would recommend everybody to download the tool and use it to reduce the time needed for figuring out how to set up the xml. Go to the CRM Sandbox download page and scroll to "FetchXML Builder".

James, thanks for sharing!



Convergence EMEA 2006

March this year I didn't make it to the Convergence in Texas. But I'll be attending the Convergence in Munich (6-8 November)! Let me know if I can meet you there. I'll assist the MS teams at the Community Lounge and Microsoft “Ask The Expert” Pavillion.

What is Convergence 2006 EMEA?
Convergence EMEA is the Microsoft Dynamics premier event, to bring customers, partners, team members and industry experts together to share ideas and knowledge. At the first annual Convergence EMEA, customers will learn how to leverage their Microsoft investment now and in the future. In addition, they will gain a stronger sense of community through interacting with industry leaders, Microsoft team members, partners and other customers.

Who should attend Convergence 2006 EMEA?
All Microsoft Dynamics customers, including those that use:
Microsoft Dynamics AX (formerly Microsoft Business Solutions Axapta)
Microsoft Dynamics CRM (formerly Microsoft CRM)
Microsoft Dynamics GP (formerly Microsoft Business Solutions Great Plains)
Microsoft Dynamics NAV (formerly Microsoft Business Solutions Navision)

With specific roles as:
Business Decision Makers
Technical Decision Makers
IT Professionals
Information Workers

Existing Microsoft Dynamics PartnersMicrosoft Certified and Gold Certified partners, especially those with the Business Solutions competency and the IW competency.

For more information:
http://www.mseventseurope.com/convergence



Reporting PreFilter

Right now I'm digging into reports more and more. I have encountered some troubles and here are some hands on experience tips.

Getting started
So... I want a report. What now?

First of all go to this url: http://www.microsoft.com/dynamics/crm/using/customizing/reporttutorial.mspx
You'll find a tutorial here named "Create a report in 15 minutes or less". This is the place to start.

Then take a look at the Report Writers Guide for additional information regarding creating CRM Reports.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/CrmSdk3_0/htm/v3d0reportwritersguide.asp

For information on how to make a report look like a crm report, look at the report style guide (pdf file in the sdk install file):
http://go.microsoft.com/fwlink/?LinkId=55779

Finally take a look at how to deal with report performance.
http://www.microsoft.com/dynamics/crm/using/customizing/reportperformance.mspx

If you want some more information on how to work with reporting services, take a look at the demo's "Introduction to SQL Server 2005 Reporting Services"
http://www.microsoft.com/technet/community/events/sql2005/SQL-06.mspx

After following those links you should be able to create great reports!

Then the real fun starts. You encounter issues. Here are some catches to think about:
- Creating a prefilter. By adding an alias to a table named CRMAF_Filtered[entityname], you can use prefiltering. A select query like "SELECT name FROM FilteredAccount AS CRMAF_FilteredAccount" is enough. This works both for reports built in VS2003 as well as VS2005.
If this doesnt work, then check that the DataProvider isn't set to OLEDB or something else. This needs to be SQL.


<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/ sqlserver/reporting/2003/10/reportdefinition" xmlns:rd="http://schemas.microsoft.com/ SQLServer/reporting/reportdesigner">
<DataSources>
<DataSource Name="CRMDEV30_MSCRM">
<ConnectionProperties>
<DataProvider>OLEDB</DataProvider>
</ConnectionProperties>
</DataSource Name="CRMDEV30_MSCRM">
</DataSources>
</Report>


- Showing the prefilter
Ok. Prefiltering works. Now we want to make the prefilter visible to the users. According to the Reporting Guide, you should add a parameter to the report with the name CRM_FilterText type string. Then you can add the value to a textbox using "Parameters!CRM_FilterText.Value". Indeed you can, but if the user selected about 10 pre filter options, then the list is unreadable. To solve this, you should add a line of code in which you replace the linefeed characters with carriagereturnlinefeed characters. Here's the code:


Public Shared Function Filter(ByVal strFilter As String) As String
Return (strFilter.Replace(vblf, vbCrLf))
End Function

Now you can add a value like this to your textbox:
= "Filter: " & vbCrLf & Code.Filter(Parameters!CRM_FilterText.Value)

- Printing landscape
The reports can be printed in landscape. Keep in mind this table:






 Height(in)Width(in)Height(cm)Width(cm)
Letter8.51121.5927.94
A48.2611.6921.0029.70

When you want to print in landscape for European sized A4 papers, then fill in the corresponding values in the PageSize field of the report: 29,7cm;21cm. For an American letter use: 11in;8,5in. You can use cm or in just as you like.

Well. Thats about it for now.

If I encounter more tips I'll add them to this list. If you have hints to share, just comment and i'll update the post.



Stop using VS 2003 and start using VS 2005 for CRM Development

Most of the development for MS CRM v3.0 I do in Visual Studio 2003. This is because callouts needs to be built on .NET Framework v1.1. All the projects built with Visual Studio are .NET Framework v2.0. Since I dont want to switch between several IDE's all the time, I only use VS 2003.

Today is the day that I found a very interesting blog posting of Arash. See this post for information on how to build your callouts in VS 2005. So, read the post, download his MSI and get rid of Visual Studio 2003!



Search

Hi,

Earlier this week I removed the popups from this page, now I have added a useful functionality. If you know for sure that I wrote an article about something, then just search for the words you remember. The textbox on the right side will only search this blog.

So far about searching the blog. Now something about searching in CRM.

Do you know on which fields of the entity the quick search is searching on? Or have you ever wanted to make the search also search another field, but it didn't work? Then you must have missed this feature: Quick Find View.

If you go to the customization page of the entity you wish to change, then go to "Forms and views". There is a view called "Quick Find Active [entityname]". On this view there is an option to set the search fields. There you can see and change the fields on which the quick find is searching on.



No more popups!

At least, on this blog...

I've been using Nedstat for sitestatistics from the start of this blog. They have been taken-over by webstats4u.com. I didn't mind that much, but ever since there have been appearing popups on the blog. Now I'm running google analytics on the blog. They give a lot nicer reports and they do that without popups! Have fun with the improved user experience :)

See here a screenshot of the report of last week:



Optimize MS CRM webservice

Currently I'm working on an import program. I have to import thousands and thousands of records. Usually the crm system is quite fast, but with these huge loads, I'm getting quite anoyed by the performance of the MS CRM webservice. It even causes error messages like "The underlying connection was closed: Unable to connect to the remote server.".

Now there are some performance tweaks available. I wanted to write a post about it, but just before I found an article written by Aaron Elder. This is a must-read for people writing code to import bulk data. However, this page has been removed, but the same information is available at Bill's blog: Blog Move: Speed Racer - Call CRM at speeds that would impress even Trixie



Fetch all records

Have you ever tried to write a code which will get you all records from a specific entity? It's harder then you think it is! Everybody who is a bit aware of the CRM SDK thinks it should be a fetch statement like this:

<fetch mapping='logical'><entity name='account'><attribute name='accountid'/></entity>

WRONG!
This would only give you the first 5000 records in the database! It is written down in the SDK with small letters, but it could drive you crazy..

There are two solutions for this issue.
1) Add a registery setting to specify not to implement MaxRowsPerPage
2) Modify the fetch statement and merge several results

Here are the details for each solution
1st solution
Search in the SDK for the word "TurnOffFetchThrottling". You should add this as DWORD registery setting to HKLM\Software\Microsoft\MSCRM. Set the value to 1. You will now not have the 5000 records limit.

2nd solution
Modify your fetch statement to include paging and count numbers. Store all the data in an DataSet and perform that series of code over and over again as long as there is data coming.

Here's the script you should use to get all accountid's (for clarity and the ease of use I have added a function called "FetchDataSet").


private DataSet FetchAllAccountIds(){
int i=1;
bool bFinished = false;
DataSet dsAllData = new DataSet();
while (bFinished == false)
{
StringBuilder sbFetch = new StringBuilder();
sbFetch.AppendFormat("<fetch mapping='logical' page='{0}' count='5000'>", i);
sbFetch.Append("<entity name='account'>");
sbFetch.Append("<attribute name='accountid'/>");
sbFetch.Append("<attribute name='new_12_accountid'/>");
sbFetch.Append("</entity>");
sbFetch.Append("</fetch>");
DataSet dsTempResult = FetchDataSet(sbFetch.ToString());
dsAllData.Merge(dsTempResult);
if (dsTempResult.Tables[0].Rows[0]["morerecords"].ToString() == "0")
{
bFinished = true;
}
else
{
i++;
}
}
return dsAllData;
}

private DataSet FetchDataSet(string fetchXml)
{
string strResult = service.Fetch(fetchXml);
DataSet ds = new DataSet();
System.IO.StringReader reader = new System.IO.StringReader(strResult);
ds.ReadXml(reader);
return ds;
}


I hope this saves you some time!

Thanks to Andrew Krivosheyenko for the Regedit solution!



Save disabled fields

Hi!

I was reading a posting of Ben Vollmer about "Doing Math in Microsoft CRM aka Calculated Field". This is an interesting article, but I noticed something in the posting that I did not know yet. There is a possibility to submit fields which are disabled! I have been using calculated fields before, but I always enabled the field when submitting the page.

So what is the solution? The use of the ForceSubmit attribute.
crmForm.all.field.ForceSubmit = true;

See the SDK for more info



MS CRM Live, open-source client for mobile devices and BizTalk integration

Today at the Worldwide Partner Conference 2006 in Boston, Microsoft has reveiled new information regarding CRM. Take a look at the press release for information regarding the the MS Dynamics CRM Live service, an open-source client for mobile devices and the BizTalk Server-based integration. Press release: http://www.microsoft.com/presspass/press/2006/jul06/07-11CRMLivePR.mspx

I'm looking forward to these products!



New MVP's

The new Dynamics MVP's are announced:

Great Plains
Duke DelPrado
Richard Whaley
Brenner Klenzman

CRM
Ronald Lemmen
Frank Lee

Navision
Ahmed Amini
Alain Krikilion

Solomon
Toni Savage

Let's congratulate them all!!

And yes, I have noticed that my name is in that list as well :) Thanks Matt Parks for nominating!!

Update:
I've added my profile to the mvp website. Click here to find me



Fix alpahabet bar in Dutch CRM

The Dutch version of CRM has a nice bug. The alphabet bar looks like:
A B C D E F G H I K K L M N O P Q R S T U V W x Y Z

As you can see, there are two bugs. The first one is the double K and the second is the lowercase x. This has finally been fixed! They are still working on the kb article pages, but you can request the fix. The KB article is: 919358. In case you can read french or italian, look here: http://support.microsoft.com/kb/919358/fr or http://support.microsoft.com/kb/919358/it. The other languages will come slowly, but thats not that important. Just request the fix :)



Modifying the fullname

The fullname of a contact is always "firstname lastname". Right? Well, did you know that you can modify this? Go to Settings, System Settings. There you can modify this setting to some other options!

Great :) So lets modify the fullname to "lastname, firstname". When saving this setting, CRM warns you that this only works for the new entities and not for the existing entities. If this really is a problem, then you can go into SQL and update the fullname manually. Here's the code to update the contacttable:

UPDATE contactbase SET fullname = ISNULL(lastname, '') + ', ' + ISNULL(firstname, '')

Of course you can update the contactbase with other values for the fullname as well.

Keep in mind that you NEVER update the Contact view, always the contactbase. Updating the contact view will cause problems.

Anyway, you should always make a backup of your database before making any modification to the database.



CrmException: Exception of type Microsoft.Crm.CrmException was thrown

Time for a new fix for a common problem.

When uploading a report you might get an error message. If this error message is:


NullReferenceException: Object reference not set to an instance of an object.]Microsoft.Crm.Reporting.SRSReport.convertDataSource(CrmContext context) +115Microsoft.Crm.Reporting.SRSReport..ctor(String name, String description, String xmlContent, String showin, String relatedentity, String category, CrmContext context, String filename, String origFilter) +136Microsoft.Crm.Reports.ReportCache.CreateSRSReport(String name, String description, String template, String showin, String relatedEntity, String category, String filename, Boolean isNewReport, String defaultFilter) +100Microsoft.Crm.Application.Platform.Report. InternalCreate(String xml) +629Microsoft.Crm.Application.Platform.Entity. Create() +109Microsoft.Crm.Application.Forms.AppForm.R aiseDataEvent(FormEventId eventId) +404Microsoft.Crm.Application.Forms.EndUserForm. Initialize(Entity entity) +56Microsoft.Crm.Application.Forms.EndUserForm. Execute(Entity entity) +13Microsoft.Crm.Web.Tools.ReportProperty. ReportPropertyPage.ConfigureForm() +202Microsoft.Crm.Application.Controls.AppPage. OnPreRender(EventArgs e) +30System.Web.UI.Control.PreRenderRecursiveInternal() +62System.Web.UI.Page.ProcessRequestMain() +1499

Then this post is not about your message. Please go to A Freaky Microsoft Dynamics CRM 3.0 Blog for a fix for this error.

Instead. If you get this message below, then read on for the solution:

[CrmException: Exception of type Microsoft.Crm.CrmException was thrown.] Microsoft.Crm.Application.Platform.Report. InternalCreate(String xml) +721 Microsoft.Crm.Application.Platform.Entity.Create() +109 Microsoft.Crm.Application.Forms.AppForm. RaiseDataEvent(FormEventId eventId) +408 Microsoft.Crm.Application.Forms.EndUserForm. Initialize(Entity entity) +57 Microsoft.Crm.Application.Forms.EndUserForm. Execute(Entity entity) +13 Microsoft.Crm.Web.Tools.ReportProperty. ReportPropertyPage.ConfigureForm() +202 Microsoft.Crm.Application.Controls.AppPage. OnPreRender(EventArgs e) +30 System.Web.UI.Control.PreRenderRecursiveInternal() +62 System.Web.UI.Page.ProcessRequestMain() +1499

I've been struggling with this error message myself and thanks to a posting on a newsgroup by LeeAC, I was able to upload my report. Here's the posting he made:

The issue lay with our RS permissions. In addition to failing to upload reports, we tried downloading them from CRM too. This gave us an NT permissions error. So, we opened up (localhost)/reports, navigated to the CRM datasource (typcially 'Organization_MSCRM), then properties, then security, and then added a user / group called NT AUTHORITY\NETWORK SERVICE, and gave them the permissions of CRM Publisher. After that it all worked fine.

Thanks

Lee



File or assembly name Microsoft.Crm.MetadataService, or one of its dependencies, was not found

Imagine.. You're writing a wonderful MS CRM 3.0 addon. After writing lines and lines of code, the time is there to run and test the addon. Instead of seeing your fantasic, state-of-the-art, rocket-science, cutting-edge addon, it is this message that arises:

Parser Error Message: File or assembly name Microsoft.Crm.MetadataService, or one of its dependencies, was not found.

Great.

Now how to solve this?

Well, Jonathan Randall has answered that question already in one of the newsgroups. Here's his posting:

The issue is caused because when you place your under application under the Microsoft CRM 3.0 web site, your application inherits the settings from the parent web site. Since the Microsoft CRM application has the two assemblies located in its own \bin folder, Microsoft CRM functions
correctly. However, your application does not have these assemblies in its \bin folder so as a result, the application fails to load. Here is some information that will correct the issue:

Symptoms: When a user attempts to access an ASP.NET web application that has its virtual directory located under the Microsoft CRM v3.0 Web Site in Internet Information Services (IIS), the following error will be displayed:

Server Error in '/' Application.
----------------------------------------------------------------------

Further detail on the error includes the following:

Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: File or assembly name Microsoft.Crm.MetadataService, or one of its dependencies, was not found.

Source Error:

Line 11: <add assembly="Microsoft.Crm.ManagedInterop, Version=3.0.5300.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
Line 12: <add assembly="Microsoft.Crm.MetadataHelper, Version=3.0.5300.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
Line 13: <add assembly="Microsoft.Crm.MetadataService, Version=3.0.5300.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
Line 14: <add assembly="Microsoft.Crm.NativeInteropProxy,
Version=3.0.5300.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
Line 15: <add assembly="Microsoft.Crm.ObjectModel, Version=3.0.5300.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

Source File: C:\Program Files\Microsoft CRM\CRMWeb\web.config
Line: 13

Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.Crm.MetadataService' could not be loaded.

=== Pre-bind state information ===
LOG: DisplayName = Microsoft.Crm.MetadataService, Version=3.0.5300.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Program Files/Microsoft CRM/CRMWeb/KBTest
LOG: Initial PrivatePath = bin
Calling assembly : (Unknown).
===

LOG: Publisher policy file is not found.
LOG: No redirect found in host configuration file (C:\WINNT\Microsoft.NET\Framework\v1.1.4322\aspnet.config).
LOG: Using machine configuration file from C:\WINNT\Microsoft.NET\Framework\v1.1.4322\config\machine.config.
LOG: Post-policy reference: Microsoft.Crm.MetadataService, Version=3.0.5300.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/kbtest/e724dea7/f72fefd/Microsoft.Crm.MetadataService.DLL.
LOG: Attempting download of new URL file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/kbtest/e724dea7/ f72fefd/ Microsoft.Crm.MetadataService/ Microsoft.Crm.MetadataService.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft CRM/CRMWeb/KBTest/bin/Microsoft.Crm.MetadataService.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft CRM/CRMWeb/KBTest/bin/Microsoft.Crm.MetadataService/ Microsoft.Crm.MetadataService.DLL.
LOG: Attempting download of new URL file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/kbtest/e724dea7/ f72fefd/Microsoft.Crm.MetadataService.EXE.
LOG: Attempting download of new URL file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/kbtest/ e724dea7/ f72fefd/ Microsoft.Crm.MetadataService/ Microsoft.Crm.MetadataService.EXE.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft CRM/CRMWeb/KBTest/bin/Microsoft.Crm.MetadataService.EXE.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft CRM/CRMWeb/KBTest/ bin/Microsoft.Crm.MetadataService/ Microsoft.Crm.MetadataService.EXE.

----------------------------------------------------------------------------
----
Version Information: Microsoft .NET Framework Version:1.1.4322.2300;
ASP.NET Version:1.1.4322.2300

Cause: Since the ASP.NET web application is located under the Microsoft CRM v3.0 web site, the application is inheriting settings that are part of the Microsoft CRM web site's web.config file. The Web.config file for a specific ASP.NET application is located in the root directory of the application and contains settings that apply to the Web application and inherit downward through all of the subdirectories in its branch. In this case, the Microsoft.Crm.MetadataService.dll and the Microsoft.Crm.Tools.ImportExportPublish.dll assemblies are being loaded by the Microsoft CRM web site. These two assemblies are located in the Microsoft CRM web application's \bin directory. Since these two assemblies are not part of the custom ASP.NET application, the Common Language Runtime begins a probing operation to locate the two assemblies. Since the assemblies are not installed into the Global Assembly Cache (GAC) or in the custom ASP.NET application's \bin folder, the exception is thrown.

Resolution:

There are four solutions to resolve the error. Each solution is detailed below.

Solution 1: Remove <add assemblies> entries in Microsoft CRM v3.0 web site's web config file.

In the <system.web> element of the web.config file, locate the <assemblies> node and remove the following entries:
<add assembly="Microsoft.Crm.MetadataService, Version=3.0.5300.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add assembly="Microsoft.Crm.Tools.ImportExportPublish, Version=3.0.5300.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

Solution 2: Install the Microsoft.Crm.MetadataService.dll and the Microsoft.Crm.Tools.ImportExportPublish.dll into the Global Assembly Cache (GAC).

The two assemblies that can be added to the Global Assembly Cache are located in the \bin directory under the Microsoft CRM web site's installation folder. A typical location would be C:\Program Files\Microsoft CRM\CRMWeb\bin.

Solution 3: Edit the ASP.NET web application's web config to remove the two Microsoft CRM assemblies.

Edit the ASP.NET application's web.config by adding the following entries to the <compilation> element that is nested in the <system.web> element of the file:

<system.web>
<compilation defaultLanguage="C#" debug="true">
<assemblies>
<remove assembly="Microsoft.Crm.MetadataService, Version=3.0.5300.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<remove assembly="Microsoft.Crm.Tools.ImportExportPublish, Version=3.0.5300.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</assemblies>
</compilation>
</system.web>

Solution 4: Locate the ASP.NET web application in a separate web site from the Microsoft CRM v3.0 web site.

Using this approach ensures that the application does not inherit any of the settings from the Microsoft CRM web site.

Jonathan Randall
Microsoft Online Support Engineer - MBS CRM Developer Support



Reporting Server not on MSCRM webserver?

If you have Reporting Server installed on a different server, then you should definately read this document:
http://www.microsoft.com/downloads/details.aspx?FamilyID=51bf9f20-bd00-4759-8378-b38eefda7b99&DisplayLang=en

This will help you to get Reporting to work again.

Happy reporting!



Callout debug: Access is Denied

I'm not sure if more people are experiencing the same thing, but at least I'd like to share this information with you.

After creating a debug build of a callout, I do copy the dll and pdb files to the \Microsoft CRM\Server\bin\assembly folder. Now I can normally debug the callout. But after modifying the code and copying the files again, then I cannot step into the code. CRM just steps over the whole callout.

When searching for a reason for this behaviour, I found a message in the event viewer. The message says:
-------------------------------------------------------------------------
Event Type: Error
Event Source: MSCRMCallout
Event Category: None
Event ID: 16912
Date: 6/22/2006
Time: 11:53:00 AM
User: N/A
Computer: CRMTest
Description:
Error: ISV code threw exception: assembly:
Microsoft.Crm.Sdk.FullSample.CalloutSample.dll; class:
Microsoft.Crm.Sdk.FullSample.Callouts.CalloutSample; entity: account,
event: precreate, exception: System.IO.FileLoadException: Access is
denied: 'Microsoft.Crm.Sdk.FullSample.CalloutSample.dll'.
File name: "Microsoft.Crm.Sdk.FullSample.CalloutSample.dll"
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String
codeBase, Boolean isStringized, Evidence assemblySecurity, Boolean
throwOnFileNotFound, Assembly locationHint, StackCrawlMark& stackMark)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef,
Boolean stringized, Evidence assemblySecurity, StackCrawlMark&
stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile, Evidence
securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm
hashAlgorithm)
at System.Activator.CreateInstanceFrom(String assemblyFile, String
typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder,
Object[] args, CultureInfo culture, Object[] activationAttributes,
Evidence securityInfo)
at Microsoft.Crm.Callout.CalloutHost.PreCreate(CalloutUserContext
userContext, CalloutEntityContext entityContext, String& entityXml,
String& errorMessage)


=== Pre-bind state information ===
LOG: Where-ref bind. Location = C:\Program Files\Microsoft
CRM\server\bin\assembly\ Microsoft.Crm.Sdk.FullSample.CalloutSample.dll
LOG: Appbase = c:\windows\system32\inetsrvLOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===


LOG: Policy not being applied to reference at this time (private,
custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft
CRM /server/bin/assembly/ Microsoft.Crm.Sdk.FullSample.CalloutSample.dll.


For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.
-------------------------------------------------------------------------

Now how to solve this?
The resolution is quite simple. After copying the files to the assembly folder, you should give the user "Network Service" full permissions. The callout will work now and you will be able to debug the code.

Good luck!

Update: Ofcourse you can also give the user "Network Service" full rights on the bin folder of your project. You will not have to modify the file then again and again.



Add descriptions to relationship view

When working with relationships, you will find out that it would be useful to add the fields "Description 1" and "Description 2" to the associated view. This means that when you're in the account detail page and you view the associated relationships, that you will not only see "Party 1", "Role 1", "Role 2" and "Party 2". The description fields are useful to store additional information, but it would be really useful if you can show this data without the need of a double click on the record.

So Ronald. How do we do this?

Usually I'd say: "go to the settings, customization, relationships, forms and views and then modify the associated view. Now there's only one small problem. There is no forms and views for the relationships entities. There are 2 entities for relationships: Customer Relationship and Opportunity Relationship. In this article I'm using only the Customer Relationship.

Well, if the link is not there, then why not create a link to that specific page? This is the solution to this problem. The link to any view modification page is:
http://localhost:5555/tools/vieweditor/viewManager.aspx?id={guid}. We only need the guid of the view which is used for the associated relationship view. We can find this id by following the next steps:

- find out the guid of any account (open an account and press CTRL+N)
- go to this url (replace the guid with your account guid):
http://localhost:5555/sfa/accts/areas.aspx?oId={60548D20-B7F5-DA11-AAE6-0003FF2689B7}&oType=1&security=4294500000&tabSet=areaRelationships
- view the source of the page
- search for "viewid"

The value of this attribute is the view guid which you should use in the url http://localhost:5555/tools/vieweditor/viewManager.aspx?id={guid}. Ofcourse you'll need to modify the port number if you have used another port.

Now you can modify the view as desired, for instance add the fields "description 1" and "description 2" to the view. After saving the modifications, you will need to publish the entity "Customer Relationship". And you're done!

Update September 4th 2007:
The article describes how to do this for the customerrelationship. If you need to do this for the opportunity relationship, then follow this url:
http://localhost:5555/sfa/opps/areas.aspx?oId={60548D20-B7F5-DA11-AAE6-0003FF2689B7}&oType=3&security=852407&tabSet=areaRelationship



10.000 Visitors

After 10.5 months of blogging, 50 posts after the "hello world" posting, this blog has been grown to what I hoped it would be. A place to find interesting information regarding MS CRM with a personal touch. Obviously this is being appreciated by the CRM community because as of this day I have had over 10.000 visitors!

Thanks to all of you!



Finally there: Show and hide fields based on the users role!

Hi all,

I've been posting around showing and hiding fields more often. I won't be talking about that now, instead I'll be discussing the ability to perform JavaScript coding based on the users role.

This solution is very neat and very clean, though unsupported!!! Now... Let's get started and dig into this.

MS CRM has a lot of Javascript codes delivered with the product. One of these codes is located here: "/_controls/RemoteCommands/RemoteCommand.js". This file is being included into every page. One of the functions in this file is RemoteCommand(sObject, sCommand, sUrlBase). You can use this function to connect to CRM webservices.

Via Javascript you can get the userid of the currently logged in user via this RemoteCommand. This is done using this code:


var command = new RemoteCommand("SystemUser", "WhoAmI", "/MSCRMServices/");
var oResult = command.Execute();


Another webservice which is interesting is the UserManager webservice. By using this function, you can get all roles of the system. The roles to which the user is assigned are marked with "checked='true'". Here's the code to get this list


var command = new RemoteCommand("UserManager", "GetUserRoles");
command.SetParameter("userIds", "<guid>" + userId + "</guid>");
var oResult = command.Execute();


Now if we add this functionality to functions and add some try catches, then you'll end up with this code:


function getUserId()
{
try
{
var command = new RemoteCommand("SystemUser", "WhoAmI", "/MSCRMServices/");
var oResult = command.Execute();

if (oResult.Success)
{
return oResult.ReturnValue.UserId;
}
}
catch(e)
{
alert("Error while retrieving userid.");
}
return null;
}

function getUserRoles(userId)
{
try
{
var command = new RemoteCommand("UserManager", "GetUserRoles");
command.SetParameter("userIds", "<guid>" + userId + "</guid>");

var oResult = command.Execute();

if (oResult.Success)
{
return oResult.ReturnValue;
}
}
catch(e)
{
alert("Error while retrieving roles.");
}
return null;
}


Now we only have to add functions which checks if the user has a specific role. The final code is:


function getUserId()
{
try
{
var command = new RemoteCommand("SystemUser", "WhoAmI", "/MSCRMServices/");
var oResult = command.Execute();

if (oResult.Success)
{
return oResult.ReturnValue.UserId;
}
}
catch(e)
{
alert("Error while retrieving userid.");
}
return null;
}

function getUserRoles(userId)
{
try
{
var command = new RemoteCommand("UserManager", "GetUserRoles");
command.SetParameter("userIds", "<guid>" + userId + "</guid>");

var oResult = command.Execute();

if (oResult.Success)
{
return oResult.ReturnValue;
}
}
catch(e)
{
alert("Error while retrieving roles.");
}
return null;
}

function userHasRole(userId, roleName)
{
result = getUserRoles(userId);
if (result != null)
{
var oXml = new ActiveXObject("Microsoft.XMLDOM");
oXml.resolveExternals = false;
oXml.async = false;
oXml.loadXML(result);

roleNode = oXml.selectSingleNode("/roles/role[name='" + roleName + "']");
if (roleNode != null)
{
if (roleNode.selectSingleNode("roleid[@checked='true']") != null)
return true;
}
}

return false;
}

function currentUserHasRole(roleName)
{
userId = getUserId();
return userHasRole(userId, roleName);
}


Now you can check for roles by using the code listed down here:

if(currentUserHasRole('Salesperson')){
alert('true');
}else{
alert('false');
}


You can copy and paste the functions as well as the last code in the form onload event. This is not really user friendly / readable though. If you copy and paste the functions to the global.js script instead, then you can use the last code snippet in the form onload.

Now. To get back to the subject "show and hide fields based on the users role"... If you modify the last code snippet to contain the showing and hiding fields as discussed in this article, instead of alert('true') and alert('false'), then you've got a very good customized system.

Thanks go out to Steven Brom (Qurius Advanced Solutions - NL) for supplying the codes!

Update 1: Thanks to Josh Painter who pointed me to the fact that I forgot to replace the < sign with <> in the codes.

Update 2: I mentioned that this solution was supported, but since we're using webservices from MS CRM other then the regular webservice, this is unsupported anyway... But still it's cool ;)

Update 3: This code doens't work on the outlook client. I'm still thinking about a solution to that.

Update 4: The code above is created for CRM 3.0. For CRM 4.0 look at the following blogs:
http://www.crowehorwath.com/cs/blogs/crm/archive/2008/05/08/hide-show-fields-in-crm-4-0-based-on-security-role.aspx
http://jianwang.blogspot.com/2008/01/crm-40-check-current-users-security.html



Hide and show fields based on the logged in user

There have been a lot of requests on how to hide and show fields since my earlier postings regarding hiding and showing fields and rows. John Straumann has written an article about this before. A working solution, but not too nice though.

Here's another solution which is unsupported (ofcourse ;) ), but it gives you a lot more freedom.

So how to tackle this problem. We already know how to hide and show fields. Now wouldn't it be great if we know what user is logged in? We would then be able to say (ofcourse modify the loggedInUser id with the guid of the user you need):


if (loggedInUser == '{123456789-1234-5678-9012-123456789012}'{
crmForm.all.name_c.style.display = 'none';
crmForm.all.name_d.style.display = 'none';
} else{
crmForm.all.name_c.style.display = 'block';
crmForm.all.name_d.style.display = 'block';
}

Now... how do we get that loggedInUser?
This is where it gets quite tricky. You can open the aspx page where you want to use this code. So why not add a little bit of asp coding in there? Lets say you want to use the code on the contact page. Then go to the server and open the "/SFA/conts/edit.aspx" page. Add this piece of code just before another script starts:

<script language="javascript">
var loggedInUser = '<%=Microsoft.Crm.Security.User.Current.UserAuth.UserId%>';
</script>


And now we have the loggedInUser! Save the file, store the javascript in the page onload and publish the contact. You will now have a page special for one user.
You can extend the codes as much as you like. You con for instance change the
Microsoft.Crm.Security.User.Current.UserAuth.UserId
with
Microsoft.Crm.Security.User.Current.IsSysAdmin
.
This all is undocumented and unsupported. Therefore you should only try these kind of modifications if you feel comfortable with this.

Good luck!



Dynamics vision of Bill Gates

Unfortunately I didn't make it to the Convergence 2006. Luckily there are other ways to get the same information as what is given there. Microsoft has posted an article on PressPass regarding Bill's vision for the new generation of Business Solutions that enable people-ready business.

Read the article here.

Most important is that Bill outlined five key and unique pillars to Microsoft's approach to role-based productivity:
- Familiar, Tailored User Experience
- Service-Oriented Architecture
- Integrated Collaboration
- Immediately Insightful
- Rapid Development Composition

Read the article for more detailed information!



Article in .NET Magazine #12

Together with Sahin Ozdemir, one of my direct colleages, I have written an article regarding MS CRM 3.0 for the nr 1 Microsoft Developer magazine in the netherlands: .NET Magazine. Ofcourse all the Dutch readers already have a free (yeah, Dutch people love free things) subscription, otherwise get one now at: http://www.microsoft.nl/magazine !

Back to the topic. We wrote an article, in Dutch, for programmer's. The main topics are:
- Customization tools
- ISV script / Form customization
- ISV code
- Import / Export
- Pre / Post-callouts
- Workflow services
- CRM Reports

A quote of one of the many replies we've got:
"This is the first time that a business application which improves productivity for programmers is exposed in a highly technical magazine on a way which is very interesting for .NET developers. This article does show perfectly what the addition is of Avanade in .NET minded Netherlands!"

Download the article here (Dutch only).



CRM Blog world

Wonderfull thing blogging. I'm doing this now for more then half a year and still am having fun to continue. But more and more blogs are coming up. There's a huge list now of people blogging mostly about MS CRM. So where is this list? Everyone has got some other blogs on their blogroll, but there is no full list. Well. Here's a list of what I think is the complete list of MS CRM blogs at the moment. Starting with the Microsoft people, then MVP's and then the other bloggers. Some blogs are marked with [inactive]. Those are blogs that have mentioned to stop or which do not have any CRM related post for the last half year. Furthermore there's no logic in the ordering. Hope you find some new information which you can use!


Microsoft Bloggers:
MSCRM Team Blog http://blogs.msdn.com/crm
MSCRM Partner Specialist Team West region http://westregioncrm.spaces.live.com/
Andrew Bybee [MS -US] http://bybeeworld.spaces.live.com/
Arash Ghanaie-Sichanie [MS - US] [inactive] http://blogs.msdn.com/arash/default.aspx
Ben Riga [MS - US] http://blogs.msdn.com/benriga/default.aspx
Ben Vollmer [MS - US] http://blogs.msdn.com/midatlanticcrm/default.aspx
Benjamin Lecoq [MS - France] http://blogs.msdn.com/benlec
Bill Patterson [MS -US] http://pattersonwc.spaces.live.com/
Charles Eliot [MS - US] [inactive] http://blogs.msdn.com/charle/
Charly Wood [MS - US] [inactive] http://blogs.msdn.com/charliew/
David Orlander [MS - Norway (language: norwegian)] http://www.crmnorway.com/
Jason Hunt [MS - US] [inactive] http://blogs.msdn.com/jasonhun/
Jim Glass [MS - US] http://blogs.msdn.com/jim_glass/
Jon White [MS - US] [inactive] http://blogs.msdn.com/jonwhite/
Jonas Deibe [MS - Sweden] http://blogs.msdn.com/jonasd/
Joriz Kalz [MS - Germany] http://blogs.msdn.com/joris_kalz/
Kevin Nazemi [MS - US] [inactive / cleared] http://blogs.technet.com/microsoftcrm/
Marcello Fisicaro [ MS - Italy] http://mfisicar.officeisp.net/blog/default.aspx
Menno te Koppele [MS - US] http://blogs.msdn.com/mscrmfreak/
Michael Rich [MS - US] [inactive] http://blogs.msdn.com/microsoft_crm_western_region_news/
Michaeljon Miller [MS - US] http://blogs.msdn.com/mikemill/default.aspx
Michaeljon Miller [MS - US] [inactive] http://inside-mscrm.blogspot.com/
Philip Richardson [MS - US] http://www.philiprichardson.org/blog/
Philip Richardson [MS - US] [inactive] http://spaces.msn.com/philiprichardson/
Philippe Brisaud and Vincent [MS - FR (language: french)] http://blogs.msdn.com/frcrm/
Prashanth Kaankadae [MS - US] http://blogs.technet.com/pkcrm/
Praveen Upadhyay [MS - US] [inactive] http://blogs.msdn.com/crmbest/
Ross Dembecki [MS - Australia] http://microsoft-crm-au.spaces.live.com/
Satya Nadella [MS - US] http://blogs.msdn.com/satyanadella
Simon Hutson [MS - UK] http://blogs.msdn.com/ukcrm/default.aspx
UK MCS [MS - UK] http://blogs.msdn.com/b/thecrmguys/

MVP's

Aaron Elder [MVP CRM - US - Ascentium] http://www.ascentium.com/blog/crm/Default.aspx
Aaron Elder [MVP CRM - US - Invoke Systems] http://www.invokesystems.com/cs/blogs/mscrm/
Aaron Elder [MVP CRM - US - Invoke Systems] [inactive] http://spaces.msn.com/members/provega/
Aaron Elder [MVP CRM - US - Invoke Systems] [inactive] http://blogs.msdn.com/aaronel
Andreas Donaubauer [MVP CRM - Germany (language: German)] http://www.crmfaq.de/
Andrii Butenko [MVP CRM - Ukraine] http://a33ik.blogspot.com/
Ayaz Ahmad [MVP CRM - Pakistan - Ovex Technologies] http://ayazahmad.wordpress.com/
Darren Liu [MVP CRM - Crowe Chizek - US] http://msdynamicscrm-e.blogspot.com/
Darren Liu [MVP CRM - Crowe Chizek - US (language: chinese)] http://msdynamicscrm.blogspot.com/
David Jennaway [MVP CRM - Excitation Ltd - UK] http://mscrmuk.blogspot.com/
David Yack [MVP ASP.NET - US - Colorado Technology Consultants] http://crm.davidyack.com/ [CRM]
http://blog.davidyack.com/ [ASP.NET]
Frank Lee [MVP CRM - US - Workopia] http://spaces.msn.com/microsoft-crm/
Frank Lee [MVP CRM - US - Workopia] [inactive] http://microsoft-crm.blogspot.com/
Geoffroy Gabel [MVP CRM - FR (language french)] http://mscrm3.blogspot.com/
Guy Riddle [MVP CRM - Australia - Snapdragon] http://guyriddle.spaces.live.com/
Guy Riddle [MVP CRM - Australia - Snapdragon] http://www.mscrm.com.au/
Joel Lindstrom [MVP CRM - Customer Effective - US] http://blog.customereffective.com/
John O'Donnell [MVP CRM - US - Crowe Chizek] http://crowechizek.typepad.com/crm/
Larry Lentz [MVP CRM - US - Lentz Computer Services] http://ts2community.com/blogs/larrylentz/
Leon Tribe [MVP CRM - Australia] http://leontribe.blogspot.com/
Marco Amoedo [MVP CRM - Spain - Plain Concepts] http://geeks.ms/blogs/marco
Matt Wittemann [MVP CRM - US - gTECHserv] http://icu-mscrm.blogspot.com/
Matt Wittemann [MVP CRM - US - gTECHserv] http://www.askcrm.com/Home/tabid/866/BlogID/15/Default.aspx
Michael Höhne [MVP CRM - DE - Stunnware] http://www.stunnware.com/crm2
Mitch Milam [MVP CRM - US - Infinite-X] http://blogs.infinite-x.net/
Nithya Balasubramanian [MVP CRM - India] http://niths.wordpress.com/
Ronald Lemmen [MVP CRM - NL - Avanade] http://ronaldlemmen.blogspot.com/
Scott Colson [MVP CRM - US] http://msmvps.com/blogs/crm/default.aspx
Umar Khan [MVP CRM - Pakistan] http://umarkhan.wordpress.com/


Company Blogs:
C5 Insight http://blogs.c5insight.com
CustomerEffective http://blog.customereffective.com/
CWRMobility http://www.cwrmobility.com/weblog/
Simego http://www.simego.com/Blog/
Sonoma Partners http://blog.sonomapartners.com/
Unitek http://www.unitek.com/training/microsoft/crm/blog/


Other Bloggers:
Abe Saldana [US] http://blog.crmbuzz.net/Default.aspx
Andrey Slepitsky [Russia (language: russian)] http://blogs.technet.com/ansle
Anne Stanton [The Norwich Group - US] http://www.crmlady.com/
Arne Janning [Germany] [inactive] http://geekswithblogs.net/insidemscrm/
Asle Berg [Columbus IT - Norway (language: norwegian)] http://dynamics-crm.blogspot.com/
Ben Hosking [UK] http://crmbusiness.wordpress.com/
Boris Kanlica [Turkey] http://www.cub-e.net/
Brian [US] http://mscrmspot.blogspot.com/
Cafe CRM [FR (language French) ] http://cafecrm.typepad.com/webblog/ms_crm/index.html
Carsten Groth [Germany (language: german)] http://carstengroth.spaces.live.com/
Catherine Eibner [Cybner - Australia] http://blog.cybner.com.au/
Christian B. Mortensen [Denmark] http://blogs.msdn.com/cbm/
Cornel Croitoriu [Romania] http://crmstuff.blogspot.com/
Craig Hamer http://blog.crmvault.net/
David Fronk [Dynamic Methods - US] http://dmcrm.blogspot.com/
David Hawes [Avanade - UK] http://blog.davehawes.com/
Dejan Dular [Slovenia] http://a-crm.blogspot.com/
Douglas Leung [Unique World - Australia] http://sharepointsix.blogspot.com/
Erik van Hoof [CWR Mobility - NL] http://www.cwrmobility.com/weblog/
Gagandeep Singh http://mscrmnovice.blogspot.com/
Gareth Tucker [Avanade - Singapore] http://garethtuckercrm.com/
George Doubinski [Australia] http://crm.georged.id.au/
Greg Owen [UK] http://thecrmgrid.wordpress.com/
Guenter [World-Direct.at - Austria] http://geekswithblogs.net/guentersblog/
Gustaf Westerlund [Logica CMG - Sweden] http://gustafwesterlund.blogspot.com/
Hans Veldman [ACI - Netherlands] http://microsoftdynamicscrm.blogspot.com/
Henry Cordes [Avanade - Netherlands] http://www.henrycordes.nl/category/CRM.aspx
Hero [India] http://www.crmsaurin.tk/
Ibrahim Sukari [RightServ - Australia] http://www.mscrmblog.net/
Imran [Pakistan] http://microsoftcrm3.blogspot.com/
Imran [inactive] http://crmexpert.blogspot.com/
Jeff Bennett [Solutions Consulting Group] [inactive] http://mscrm-notes-from-the-field.blogspot.com/
John O'Connor [US] http://crmnit.blogspot.com/
John Straumann [Canada] http://mscrmguy.blogspot.com/
John Straumann [Canada] [inactive] http://blogs.msdn.com/jstraumann
Julian Sharp [active again!] http://spaces.msn.com/members/mscrm
Keith Delarge [Aspective - UK] http://www.mscrmblog.com/
Kjell-Sverre Jerijærvi [Objectware - Norway] http://kjellsj.blogspot.com/
Luis Mazario [Spain (language: Spanish)] http://blogs.msdn.com/crmlandia
Maarten Dominicus [NL] http://www.crmwatcher.com/
Mads Nissen [Norway] [inactive] http://weblogs.asp.net/mnissen/category/5782.aspx
Maik Roempagel http://blog.codealchemist.com/
Marcello Tonarelli [VAR Group - Italian] http://marcellotonarelli.wordpress.com/category/ms-dynamics-crm/
Mario Raunig [World-direct.at - Austria] http://marioraunig.blogspot.com/
Mike Snyder [Sonoma Partners - US] http://blog.sonomapartners.com/
Mike Taylor [UK] http://crmuser.blogspot.com/
Neil Huffman [Productivegap - US] http://nhuffman.spaces.live.com/
Oguz KIRIS [Turkey] http://www.crm4.ws/
Olivier Furnemont [METRUM SàRL - LUX] http://www.furnemont.eu/
Oshri Cohen [Canada] http://mymscrm3.blogspot.com/
Peter Florijn [NL] - http://customcrm.blogspot.com/
Peter Maude [inactive] http://www.tconv.com/blogs/crm3tips/
Phil Adams http://blog.expertsoftware.co.uk/
Pierre Hulsebos [EHTC - US] http://blog.solomon2crm.com/
Rich Oyler & Nicholas Cole [Saratogaus - US] http://crmblog.saratogaus.com/
Rob Bakkers [Avanade - NL] [inactive] http://robbakkers.blogspot.com/
Robert MacLean [South Afrika] http://www.sadev.co.za/
Robert Peledie [UK] http://www.crmrocks.net/
Robert Peledie [UK] http://www.crmconsult.info/
Roberto Nocera [Avanade - Italy (language: italian)] http://blogs.ugidotnet.org/rnocera
Roberto Vecchio [Italy (language: italian)] http://blogs.ugidotnet.org/roblog/
Ron Kane [Scotland] http://mscrminscotland.blogspot.com/
Ross Lotharius [Ascentium - USA] http://rosslotharius.com/
Ryan Farley [inactive] http://crmdeveloper.com/blog
Sandor Schellenberg [Atos Origin - NL] http://friendlycrmonster.blogspot.com/
Seidl Michael [Germany (language english/german)] http://mscrm.m-seidl.com/
Seth Kircher [Navint - US] http://navintmicrosoftcrm.blogspot.com/
Stéphane Dorrekens [Belgiu] http://blog.dorrekens.com
Stephen Maij [SeeSharp - NL] http://www.maijspace.nl/
Steve Boyce [UK] http://blog.crmvault.net/
Wim Coorevits [U2U - Belgium] http://www.u2u.info/Blogs/WimCo
Wolter Kreun [Netherlands] http://www.crmmaps.com/
Wolter Kreun [Netherlands] http://skypecrm.blogspot.com/
Xavier Courchinoux http://blogs.msdn.com/xavier_courchinoux/

General CRM Blogs
Aina Neva Fiati [Indonesia] http://www.crmpieces.blogspot.com/



MS CRM SDK 3.0.4

Microsoft posted the newest version of the SDK for MS CRM 3.0 yesterday. We're on version 3.0.4 now.

Download the SDK here.

Overview
The Microsoft CRM 3.0 SDK is for developers, system customizers and report writers. It contains the following sections:

Server Programming Guide – A guide for developers writing server side code, custom business logic, integration modules, workflow assemblies and more. This guide provides an architectural overview of Microsoft CRM, the entity model, security model, Web services, and sample code.

Client Programming Guide – A guide for developers customizing the Web client or the Microsoft CRM client for Outlook, including scripting, integration of custom Web pages, and sample code.

ISV Programming Guide - A guide for independent software vendors (ISVs) developing installable add-ins for Microsoft CRM.

Report Writers Guide - A guide for developers writing reports for Microsoft CRM using Microsoft SQL Server Reporting Services Report Designer.



Hiding rows

Hi!

Have you already tried to remove fields as described in this article?

I've been using this quite some time now, but I noticed something weird. When you have removed two fields which are on the same line, then you don't want to see this row at all. Well, this doesn't work by default.

By using jscript you'll need to access the table row and hide it. This doesnt work with the style.visibility = 'hidden'. Instead, you should use this line:


crmForm.all.field.parentElement.parentElement.style.display = 'none';

This row should remove the whole line. Yes, thats what it should do. So if it doesn't do that, what does it do? It removes everything except for picklists. You’ll need to hide those manually as described in the other article:
crmForm.all.picklist_d.style.display = 'none';


It's not business critical, but it does fine-tune your UI when working with advanced UI manipulation.

Good luck!

Update:
Robert Amos mailed me his solution. He's hiding complete sections. Here's part of his mail:

I usually pick the first (top left) field in CRM and work on it:
crmForm.all.firstfield_c.parentElement.parentElement. parentElement.style.display = 'none';

That should pick the element containing the entire section and suck it out of the form. So I've been hiding non-relevant sections so the user doesn't get confused. Keeps it clean :)



Readonly fields

Ryan Farley has written a nice article about making fields readonly. Ryan has written several good articles from a developers point of view. I expect there will be more good work coming from his hands. Welcome in the world of CRM bloggers Ryan!



Wintersport

It's been a while since my last posting. Well, for that I do have a good reason. I've been in France, Alpe d'Huez, for a week for winter holidays. Until the day before my holidays I didn't know for sure if I could go on holidays because of a high priority CRM project. Luckily for me the project has been delayed and so I have been snowboarding a week long!

I've been back for several days now but I'm still walking around with pain in my muscles. Not too weird though if you know that every day me and my friends started with a black piste for warmup and furthermore spending the day off-piste and in the funpark ;-)

Here's a picture of me with one of the jumps last week.

Are there more snowboarders who work with CRM? Or should I put it the way around: Are there more people who work with CRM and do a bit of snowboarding in their spare time? ;)



How to rename area's

Quite often I see the question "how do I rename an area in CRM v3.0?".

I could write an own example, but Arne Janning already did so in the public community. Here's his post:

In the CRM-web-client click --> Settings --> Customization --> Export Customizations --> mark Site Map --> More Actions --> Export Selected Customizations --> Hit OK on the dumb dialog.

You get a customizations.xml-file to download. In that file you'll find five area-elements: Workplace, SFA, MA, CS, Settings. These areas define the top-level structure of the "Wunderbar" (the Outlook-style navigation).

This is an example for an area-element:
<area id="SFA" shape="RECT" coords="0,0,0,0" resourceid="Area_Sales" icon="/_imgs/sales_24x24.gif" descriptionresourceid="Sales_Description">
To customize this you could add the "Title"-attribute to overwrite the ResourceId:

<area id="SFA" title="Clients" shape="RECT" coords="0,0,0,0" resourceid="Area_Sales" icon="/_imgs/sales_24x24.gif" descriptionresourceid="Sales_Description">The strucure of the sitemap is well documented in the SDK, which BTW has been updated and improved lately :o)

Microsoft CRM 3.0 SDK

Client Programming Guide --> Navigation Configuration: SiteMap

Once you have finished your customizations in the sitemap you can upload the again:

Settings --> Customization --> Import Customizations --> select your file --> upload, publish and hit F5 to reload the Wunderbar.

Hope that helps.



Getting inside MS CRM

If you think that solutions which are on this blog are unsupported, then take a look at the post which my new German colleague Arne Janning has posted:

Getting inside Microsoft CRM - Part I

He'll get you virtually inside crm and from there you will be able to do anything that you have ever wanted to do with MS CRM.

I'll have to warn you: if you don't feel comfortable with what you see, then just don't try this. You'll likely be messing up your (clients?) system :-)