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

Leave a Reply

Your email address will not be published. Required fields are marked *