Microsoft Dynamics CRM

Monday, August 14, 2006

Viewing linked entities in information tab

A lot of clients want to view the most important data inside of the first page that pop-ups in a new page.

For example they want to see all the contacts that are involved in a project. Normally they would have to open the project entity and click on the project members on the left side. Well with an Iframe and some javascript you can do this in a different way.

The code which is put in the OnLoad event of a form:
-----
var sArea = "[entity1]_[entity2]s";
var sBaseUrl = "http://servername/userdefined/areas.aspx?";

html = sBaseUrl;
html += "oId=" + crmFormSubmit.crmFormSubmitId.value;
html += "&oType=" + crmFormSubmit.crmFormSubmitObjectType.value;
html += "&security=" + crmFormSubmit.crmFormSubmitSecurity.value;
html += "&tabSet=" + sArea;
document.all.IFrame_Test.src = html;
-----

the sBaseUrl depends if the relationship is customentity to customentity (http://servername/userdefined/areas.aspx?) or entity to customentity (http://servername/areas.aspx?).

The sArea name is a combination of the two linked entites. Entity1 is the entity of the form and the second one is the linked entity (don't forget the 's' at the end). If we for example have two entities of which the schema name is new_test1 and a second entity new_test2 the sArea would be: "new_test1_new_test2s".

The result of this is:

Monday, March 13, 2006

Data validation using regular expressions

Client side data validation can be a very powerfull tool within CRM 3.0. The new CRM gives more options to add javascript out-of-the-box.

The following sample uses a regular expression to check if a field contains a valid dutch postal code. We check it when changing a field and also on the OnSave event of a form.

Onchange:
var oField = event.srcElement;

if (typeof(oField) != "undefined" && oField != null)
{

if(oField.DataValue != "" && oField.DataValue != null)
{
var reg = /^\d{4} ?[a-z]{2}$/i;

if (!reg.test(oField.DataValue))
{
alert(“Invalid postal code”);
oField.SetFocus();
}
}
}

Onsave (change field name):
var oField = crmForm.all.address1_postalcode;

if (typeof(oField) != "undefined" && oField != null)
{
var reg = /^\d{4} ?[a-z]{2}$/i;

if (!reg.test(oField.DataValue))
{
alert("Fill in a correct postal code");

oField.SetFocus();

event.returnValue = false;
return false;
}
}

Update header information

Sometimes it can be usefull to have some more information in the header of an entity. When switching to an activity history overview, sometimes seeing the account name is just not enough. This can be fixed with some very easy javascript.

In the code we first loop through the td elements to find a td element which has a class of formTitle assigned to it. This td contains the header text. We just add any field we want to it.

javascript:
var doc = document.getElementsByTagName('td');
for (var i = 0; i < doc.length; i++)
{

if(doc[i].className == "formTitle")
{
var header = doc[i].innerText;

//address1_line1
if (typeof(crmForm.all.address1_line1) != "undefined" && crmForm.all.address1_line1 != null)
{
if(crmForm.all.address1_line1.DataValue != "" && crmForm.all.address1_line1.DataValue != null)
{
header = header + " | " + crmForm.all.address1_line1.DataValue;
}
}

doc[i].innerText = header;
}
}

Monday, February 13, 2006

Workflow/Import troubles

With some installations the Import and workflow will not be working as well as we would want to. Imports keep pending instead of being imported or workflow rules not being triggered.

Try to set the account for the Microsoft CRM Workflow Service to Local System or NT Authority.

Also try to create the workflow rules with another user than the special account which installed the CRM Server.

These changes might help with the import and workflow problems.

Tuesday, January 31, 2006

CRM 3.0 Sample Data tool

When importing the Sample data for CRM 3.0 using the tool, you need to take in account that the number of users returned from AD has a maximim of 1000. I had some contact with the people from Microsoft and it seems this is by design to minimize the load on the AD.

So if you want to use the Sample Data tool for CRM 3.0 and want to do so on an environment with more than 1000 users in Active Directory, make sure you create an account with has less permissions. Give the account permissions to a specific OU where the users are stored. This way you should get the users you want.

Friday, January 27, 2006

Settings disappearing in CRM 3.0

Today I was running into some troubles with the CRM 3.0 webapplication not showing the Settings section. When I manually opened the pages for editing, exporing, etc error messages would be shown. I was working on a Virtual PC which had crashed the day before.

The problem seemed to occur when the Virtual PC crashed and the Outlook Client was running. The CRM application checks if someone is using the Outlook Client and if so, the settings area won't be available.

So starting Outlook and closing it again solved this problem.....

Sunday, January 08, 2006

First Blog

Last week I was rewarded as a Microsoft Dynamics CRM MVP. Because of this award I decided to start my own blog and try to help the community even further.

The main goal of my blog is not to post news on Dynamics CRM but to provide know-how on developing for the CRM product.