jump to navigation

Auto populate fields in CRM 4.0 using Javascript onChange event August 14, 2008

Posted by Joel Kriel in CRM 4.0 & .Net development.
Tags: , , , ,
add a comment

A few enhancements from our clients that have been coming down the pike is to auto-populate fields based on selection criteria from other fields, specifically the picklists. One client has a field that is used to select an ‘English honorific’ for the contact. (Mr., Mrs, Ms, etc.). Based on that selection, they want to pre-populate the salutation field with the last name and the prefix. (Mr. Smith)

Here is the code snippet that we can use to populate the salutation field based on the value of the picklist given via Javascript using switch. This is to be used on the obChange event of your specific attribute.

var MrMrs;
var LastName;

LastName = ”;

if (crmForm.lastname.DataValue != null)
{
LastName = crmForm.lastname.DataValue;
}

MrMrs = crmForm.new_mr_mrs.SelectedText

if (crmForm.salutation.DataValue == null)
{
crmForm.salutation.DataValue = MrMrs + ‘ ‘ + LastName;
}

Granted there are going to be many ways to do this, I just figured this might be the easiest for fellow developers to understand and thus support.

Cheers!

Follow

Get every new post delivered to your Inbox.

Join 57 other followers