Error: "Unable to connect to the remote server"

To resolve this error you can edit registry at MS CRM Server - look through the article (PartnerSource) at Microsoft Dynamics: KB913515

Also here is another way, to use the unsafe connection sharing.
Article at blogs.msdn.com: "Best Practices for Better Performance from Your Custom Code"


MS CRM database fragmentation

If your CRM is very slow, then check the indexes fragmentation.
And if received table was not empty then you must rebuild the indexes.

USE AdventureBase
SELECT a.index_id, name, avg_fragmentation_in_percent
FROM sys.dm_db_index_physical_stats (DB_ID(N'AdventureBase'), NULL,NULL, NULL, NULL) AS a
JOIN sys.indexes AS b ON a.object_id = b.object_id AND a.index_id = b.index_id
where avg_fragmentation_in_percent>30


Replace non-digit symbols with RegEx

If you need to restrict input in nvarchar field(only the digit symbols for example), you may write some code to OnSave() event.
This code is replace all of non-digit symbols in new_telephonenumber field to nothing, i.e. "".

//before: new_telephonenumber = "555-555$#5"
//after: new_telephonenumber = "5555555"

var re = /\D/g;
if(document.crmForm.all.new_telephonenumber.DataValue != null){
crmForm.all.new_telephonenumber.DataValue = crmForm.all.new_telephonenumber.DataValue.replace(re,"");


The Microsoft Dynamics CRM Developer Toolkit

Microsoft Dynamics CRM 4.0 toolkit for Visual Studio 2008. Download link


Test before save

I don't want to write a server code if I can do the same at the client side.
Here is the test for INN field, that must contain only the numbers.

var re = new RegExp("[^0-9]");
if(crmForm.all.new_inn.DataValue != null){
if(re.test(crmForm.all.new_inn.DataValue == true){
alert("ИНН должен содержать только цифры");
event.returnValue = false;
return false;


Error: 0x80042f09 SecLib::CheckPrivilege failed. Returned hr = -2147209463

If you get an exception like next one:

SecLib::CheckPrivilege failed. Returned hr = -2147209463, User: 529cc8c0-23b6-dd11-a373-001cc458db68

You should check the user roles, because the error code 0x80042f09 means "The user has not been granted any licenses or the user has not been assigned any roles."
The user can have the role that can have no rights to the entity or to the entities witch have the owner-member relationship with base entity.
For example:
We have two entities organization -> opportunity and one role "salesperson" with rights on the organization and no rights to the opportunity. If you set the user with just "salesperson" role to the Owner of some organization, you will get the error 0x80042f09.

Same is fair to all errors "SecLib::CrmCheckPrivilege failed."