Passing Exam MB2-631 Microsoft Dynamics CRM 4.0 Customization and Configuration


Hi,

Last week I took this exam and passed with a score of 98. For preparation I used the following training material.

Course 8912: Customization and Configuration in Microsoft Dynamics CRM 4.0 and Working with Microsoft Dynamics CRM 4.0 (Microsoft Press).

I felt the course 8912 training material is more than enough for passing the exam.

(Chapter 11: Introduction to Advanced Customizations :- There weren’t any questions from this chapter it’s just there for our own understanding).

Bye….

0x80040220 SecLib::CrmCheckPrivilege failed. Returned hr = -2147220960 on UserId: dd80d8b7-6700-dd11-9838-001185e68627 and PrivilegeId: 0b609bc5-afb0-4576-8db0-7ad715375833 Platform


Hi,

We upgraded from CRM 3 to CRM 4, and certain users got this error while trying to access the CRM.

We realized that the users receiving this error had our own custom security role assigned to them. i.e System Primer.

When we assigned them any of the existing default security role there was no problem in accessing the CRM.

So the way we resolved was to assign a default security role and our own custom role to the user, so that he could access the system for the first time without any issues and

after the user has accessed it once than we removed the default security role.

This approach worked for us!!!!

Or another thing that worked was if we are assigning any custom role to users, we gave the write permission for user settings in that custom role.

the kb article for this error are

http://support.microsoft.com/kb/953962/en-us

http://support.microsoft.com/kb/952279/en-us

Bye

0x80041102 -the entity with ObjectTypeCode = 4408 was not found in the Metadata Cache. Platform


I was receiving this error while I was using the tool JSExportFromCRM – a useful tool to backup javascripts for CRM.

While looking for the same the solution I found was this

First I ran this query

SELECT * from entity WHERE objecttypecode = 4408

It returned nothing

Than I ran the following query and it

select * from organizationuibase where ObjectTypeCode = 4408

returned a row.

So ran the following query (i.e deleted that entry)

Delete from organizationuibase where ObjectTypeCode = 4408

And than again run the tool and it worked properly!!

Bye

Url Behaviour – Asp.NET web service


When adding a webreference to a webservice in visual studio we can set the Url Behaviour property inside visual studio.

In visual studio 2003 by default it is set to static and in visual studio 2005 it is set default to dynamic.

Static means the url is set in the code within the generated proxy class Reference.cs.

Normally this file doesn’t show up in visual studio. Using Show All Files option in visual studio displays this file.

This is what would be there in generated proxy class for Url Behaviour Static

public CrmService() {

this.Url = http://d-3324:5555/mscrmservices/2006/crmservice.asmx”;

And in case of Dynamic we will find a corresponding entry for the url in our application config file.

<applicationSettings>

<WindowsFormsApplication1.Properties.Settings>

<setting name=WindowsFormsApplication1_CrmSdk_CrmService serializeAs=String>

<value>http://d-3324:5555/mscrmservices/2006/crmservice.asmx</value>

</setting>

</WindowsFormsApplication1.Properties.Settings>

</applicationSettings>

And inside our proxy class

public CrmService() {

this.Url = global::WindowsFormsApplication1.Properties.Settings.Default.WindowsFormsApplication1_CrmSdk_CrmService;

Bye

Updating value in CRM entity in Callout written for Update event


 

Well we had a requriement in our case where we wanted to update a particular attribute value in our Crm’s opportunity entity in our update callout.

While looking for the same I came to know that if we are updating any attribute’s value in the entity against which we have attached our update callout, we will be lost in infinite loop.

Only way to do this is in the PreUpdate and there is a sample code for the same in sdk as well.(Unsupported)

public override PreCalloutReturnValue PreUpdate(CalloutUserContext userContext,CalloutEntityContext entityContext, ref string entityXml,ref string errorMessage)

Here we can see that the entityXml is passed to us as a reference. So any modification made to the entityXml would reflect back in that entity’s form as well.

Suppose this is the entityXml which we receive in our PreUpdate event

<?xml version=1.0 encoding=utf-16?>

<BusinessEntity xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:xsd=http://www.w3.org/2001/XMLSchema xsi:type=DynamicEntity Name=opportunity xmlns=http://schemas.microsoft.com/crm/2006/WebServices>

<Properties>

<Property xsi:type=KeyProperty Name=opportunityid>

<Value>57330ec3-6f5d-dd11-acd2-00164145e126</Value>

</Property>

<Property xsi:type=CrmFloatProperty Name=new_estimatedvalue>

<Value>1</Value>

</Property>

<Property xsi:type=CrmMoneyProperty Name=estimatedvalue>

<Value>77.5</Value>

</Property>

</Properties>

</BusinessEntity>

Now after running this code in our preUpdate event handler we can add a new property tag itself, which would be refering to the attribute we would like to update

// creating an xmlDocument

XmlDocument entityDoc = new XmlDocument();

// loading the entityXml in it

entityDoc.LoadXml(entityXml);

// the attribute which we would like to update

XmlElement totatForecastedValue = null;

// get the list of properties

XmlNodeList propertyList = entityDoc.GetElementsByTagName(“Property”);

XmlElement properties = (XmlElement)entityDoc.GetElementsByTagName(“Properties”)[0];

// creating an element with property tag

XmlElement totalForecastedElement = entityDoc.CreateElement(“Property”);

// creating an attribute type for the property tag

XmlAttribute typeAttrib = entityDoc.CreateAttribute(“type”);

totalForecastedElement.SetAttribute(“type”, http://www.w3.org/2001/XMLSchema-instance&#8221;, CrmFloatProperty”);

totalForecastedElement.SetAttribute(“Name”, “new_totalbilling”);

totatForecastedValue = entityDoc.CreateElement(“Value”);

// setting the value for the attribute

totatForecastedValue.InnerText = “10”;

totalForecastedElement.AppendChild(totatForecastedValue);

properties.AppendChild(totalForecastedElement);

 

//saving the output

StringWriter output = new StringWriter();

entityDoc.Save(output);

 

// assigning the same output to the entityXml

entityXml = output.ToString();

 

// Remove extra XML that will confuse CRM.

entityXml = entityXml.Replace(“xmlns=\”\””, “”);

entityXml = entityXml.Replace(“<?xml version=\”1.0\” encoding=\”utf-16\”?>”, “”);

The entityXml gets modified with the above code in this manner

<BusinessEntity xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:xsd=http://www.w3.org/2001/XMLSchema xsi:type=DynamicEntity Name=opportunity xmlns=http://schemas.microsoft.com/crm/2006/WebServices>

<Properties>

<Property xsi:type=KeyProperty Name=opportunityid>

<Value>57330ec3-6f5d-dd11-acd2-00164145e126</Value>

</Property>

<Property xsi:type=CrmFloatProperty Name=new_estimatedvalue>

<Value>1</Value>

</Property>

<Property xsi:type=CrmMoneyProperty Name=estimatedvalue>

<Value>77.5</Value>

</Property>

<Property xsi:type=CrmFloatProperty Name=new_totalbilling >

<Value>10</Value>

</Property>

</Properties>

</BusinessEntity>

 

And this way our entity gets updated as well.

And the same code in CRM 3.0 callout  works properly in case of upgrading the CRM 3.0 server to CRM 4.0 .

 

Bye..

 

 

Modifying the Convert Lead Web dialog box in CRM


Hi,

We had a requirement of not allowing the user to convert the lead to an account or contact through the convert lead dialog box.

That required change the soucre code of the convert lead dialog box’s web page. (This is not supported)

I found the page at the following location

“C:\Program Files\Microsoft Dynamics CRM\CRMWeb\SFA\leads\dialogs\conv_lead.aspx”

Opened it in Visual Studio 2005

and used the div tag for hiding the check boxes for account and contact.

<tr >

<td>

<div style=”display:none;” >

<input class=”checkbox” type=”checkbox” id=”cbAddAccount” onclick=”updateUIState()” <%= (Microsoft.Crm.Security.User.GetPrivilege(CurrentUser, Privileges.CreateAccount )) ? “editable” : “disabled” %>>

</div>

</td>

<td>

<div style=”display:none;” >

<label for=”cbAddAccount”><% =Microsoft.Crm.CrmEncodeDecode.CrmHtmlEncode(Util.GetFmtObjName(Util.Account, Util.NameFormatStyle.Singular)) %></label>

</div>

</td>

</tr>

<tr >

<td>

<div style=”display:none;” >

<input class=”checkbox” type=”checkbox” id=”cbAddContact” onclick=”updateUIState()” <%= (Microsoft.Crm.Security.User.GetPrivilege(CurrentUser, Privileges.CreateContact )) ? “editable” : “disabled” %>>

</div>

</td>

<td>

<div style=”display:none;” >

<label for=”cbAddContact”><% =Microsoft.Crm.CrmEncodeDecode.CrmHtmlEncode(Util.GetFmtObjName(Util.Contact, Util.NameFormatStyle.Singular)) %></label>

</div>

</td>

</tr>

It worked !!

Bye..