Monday, July 31, 2006

Generating T.a.v and Briefhoofd for the Dutch Microsoft CRM users

This javascript example can be used to create an "t.a.v" and "briefhoofd" for the
Dutch version of Microsoft CRM. Ofcourse this can also be modified to use in other
languages. I'm just lazy to put it in an other language...

It can be expanded with specific language settings if the CRM instance is used to save Contacts with from different countries.


var strAanhef;
var strBriefHoofd;
var strMiddleName;
var str1;
var str2;

if( crmForm.all.gendercode.DataValue == 1 )
{ strAanhef = "T.a.v. de heer" strBriefHoofd = "Geachte heer"};

if( crmForm.all.gendercode.DataValue == 2 )
{ strAanhef = "T.a.v. mevrouw" strBriefHoofd = "Geachte mevrouw"};

//..Aanhef functionscrmForm.salutation.value = strAanhef + IsNull

(crmForm.all.pager.DataValue) + IsNull(crmForm.all.nickname.DataValue) + IsNull(crmForm.all.middlename.DataValue) + IsNull(crmForm.all.lastname.DataValue) + IsNull(crmForm.all.suffix.DataValue);

//..BriefhoofdcrmForm.new_briefhoofd.value = strBriefHoofd + WordCapitalize

(crmForm.all.middlename.DataValue) + IsNull(crmForm.all.lastname.DataValue) + IsNull(crmForm.all.suffix.DataValue) ;

function IsNull( value )
{if("undefined" == typeof( value ) "unknown" == typeof( value ) null == value )
return "";
else
return " " + value;}

function WordCapitalize(word)
{if ( "undefined" == typeof( word ) "unknown" == typeof( word ) null == word ) return "";
else
return " " + word.charAt(0).toUpperCase() + word.substring(1, word.length);}

2 reacties:

Anonymous said...

Nice and usefull script, thanks.

The thing is, you don't want to add this code in every single field on the form that is used by Tav and Briefhoofd. In case of changes you need to change the onchange code on all x fields.

As far as i know it's not posible to write a function for this in form onload, that can be called from the related fields. Do you know how to do this?

(you can reply in dutch if you want)

Dutch CRM guy said...

I'm writing this in English for our readers... :)

What you can do is put the function in a .js on your CRM server in a virtual directory and reference it from the Onload Event. In the field that contains the On Change for triggering the fields, put the name of the function you need to call. By using this method you can centrally maintain your javascripting.

For an example see the post of Mitch Milam

http://blogs.infinite-x.net/2006/02/18/including-custom-javascript-files-in-mscrm-30/print/