Automatic salutation for contacts in CRM 4.0

I was asked to bring more uniformity in the use of the Salutation attribute in CRM. In this case, the field is used to contain the Dutch equivelant of “Mr” and “Mrs”. But there should be an option to give a contact a different or additional salutation.

Here’s how it’s resolved:

Initial Contacts formInitially, the Contacts from holds the Salutation text field. We want to reuse this field, but make it more consistent.

On the 2nd tab (Details), there is a dropdown listbox for Gender:

Gender ddlbThis attribute is optional and contains two values, Male and Female.

First we move the Gender field to tab General, section Name.

moved genderNext, open the field properties and go the the event tab:

field propertiesEdit the onChange event and add the following code:

// Declare saltutation constants
var maleSalutation = "De Heer";
var femaleSalutation = "Mevrouw";

// Retrieve the gender of the contact, if it is empty, then
var lookupvalue = 0;
if (crmForm.all.gendercode.DataValue != null)
    lookupvalue = parseInt(crmForm.all.gendercode.DataValue);

// Fill the Salutation field if it is empty or filled with one of the salutations
if (crmForm.all.salutation.DataValue == null || crmForm.all.salutation.DataValue == "" || crmForm.all.salutation.DataValue == maleSalutation || crmForm.all.salutation.DataValue == femaleSalutation)
        case 1:
            crmForm.all.salutation.DataValue = maleSalutation;
        case 2:
            crmForm.all.salutation.DataValue = femaleSalutation;
            crmForm.all.salutation.DataValue = "";

Enable the event and add the fields “Gender” and “Salutation” to the dependent fields.

After you publish the changes, the Salutation field will update to contain one of the the chosen values defined in maleSaltutation and femaleSalutation, whenever the gender attribute changes, unless a different salutation is provided:

end result

Modifying the Account form to hold visiting and postal address in MS Dynamics CRM 4.0

I was asked to modify the Accounts Form in Microsoft Dynamics CRM 4.0, to better match the company and Dutch way of working with addresses. Among others, I wanted to show both the visiting and postal addresses for a company in the same screen.

The Account Form already had some minor modifications; such as making the Primary Contact and Relationship Type recommended values. The Account also already shows a section ‘Address’ with it’s most important attributes. As there was no shipping to customers, attributes such as Shipping Method and Freight Terms could be left out.

The main problem with the current form was the fact that there is only one address on the form, while most accounts have (at least) two addresses that need to be recorded: it’s visiting and postal address (which can be the same, but often differ). One solution could be to use the “More Addresses” list, but these are ‘generic’ address entities that are linked to the account. What many don’t know is that an account has additional address fields which can hold this information.

Here’s how you go about altering the Account form:

rename address section

Go to SettingsCustomizationCustomize Entities, open th account entity and then open the main application form. Next, remove the unwanted attributes from the form and rearrange it.

rename address section

Rename the address section to Visiting Address.

add new sectionThen add a new section below the visiting address: Postal Address.

add fields to sectionSelect the fields from the Address2 collection that you want to use in the Postal Address, in my case these were the same fields as the visiting address.

rearrange fieldsThe fields will be added in the same order in which they are listed in the Add Fields dialog so they’ll have to be rearranged.

rearranged and renamed fieldsRearrange and rename the fields to suit your purpose.

Both addresses also have an Address Name attribute. This field is (often) used to display the organisation name when printing an address. I want it to be equal to the Account Name by default, but still allow the users to modify it to their exact needs. To make this easy, I implemented a client-side script that runs on the OnSave event for the

// Retrieve the name of the account, if it is empty, then use an empty string
var lookupvalue = "";
if ( != null)
    lookupvalue = String(;

// Fill the Visiting and Postal Address Name fields ('address1_name' and 'address2_name') if they are empty
if (crmForm.all.address1_name.DataValue == null || crmForm.all.address1_name.DataValue == "")
    crmForm.all.address1_name.DataValue = lookupvalue;

if (crmForm.all.address2_name.DataValue == null || crmForm.all.address2_name.DataValue == "")
    crmForm.all.address2_name.DataValue = lookupvalue;

OnSave event codeMake sure you enable the event.

Set dependencies

It’s also wise to set the dependencies for the script, so the fields cannot be removed.

Now when a user saves the form, the Address Name fields for the visiting and postal addresses will be filled with the (mandatory) Account Name field. The Address Name fields are not read-only, so users can override this setting. If they already did fill the fields, they will be left untouched.

In this case, CRM is also used in Dutch, so I’ll have to provide translations for the renamed and added form elements.

Dutch versionThis is what the form looks like in Dutch, before translating. Export Labels for Translation and open them in Excel or your favorite Xml editor.

Translating itemsTranslate the labels. The ones for the Address 2 fields will be empty initially.

End result in DutchAnd here’s the end result in Dutch. All that’s left now is to define the address types for Address 2 (and for the visiting address, if required).