718 Washington Ave. N. Suite #101
Minneapolis, MN 55401
View map and all Locations

Send us a message

If you’ve created a custom entity in Microsoft Dynamics CRM 2011 (or CRM 4 for that matter) you’ve noticed the “Name” field of this entity is a required field. What if this field serves no useful purpose for your users. It could just be an extra field that the user must populate in order to save a new record.


You could easily auto populate that field with a static value; however, since this field shows up (and is required) in many of the system views and well as the Lookup field on related forms, this is probably not the best option. A better option might be to have CRM (with the help of a simple javascript) automatically populate the current Date/Time that the new record was created. This will make the Name field useful while satisfying CRM’s appetite for wanting the field populated with some value.

In the example below, the custom entity was set as an Activity Type. These types of entities will (by default) rename the required field to “subject”.

Custom Entity Microsoft Dynamics CRM

Since this is a standard text field, the following script will result in an error since we are attempting to populate a date value into a text field.

[code lang=”js”]

function subject()

{ if (crmForm.all.subject.DataValue==null)


crmForm.all.subject.DataValue=new Date();



Auto Populate MSCRM

Instead, we need to convert this date value to a string.

Here is the proper code:

[code lang=”js”]

function subject()

{ var now = new Date();

if (crmForm.all.subject.DataValue==null)






Executing this code onLoad of the form with first check to see if the “subject” field contains data. If it does contain data, the script will not modify it. If the subject field is blank, it will populate the current date as a string as shown in the view below.

In most cases, it is recommended that the Name/Subject field for every entity is used to populate a value that uniquely identifies that record. But for those instances where it’s simply an extra field that users are required to populate, this might be a viable option.

(Javascript gettin you down? Is this stuff too technical for you or your team. Feel free to reach out to our MSCRM Experts….we’d love to help on your next project.)

Happy CRM’ing!

Avatar for JoeCRM


Joe CRM is a CRM superhero who runs on pure Microsoft Dynamics CRM adrenaline. As the face of PowerObjects, Joe CRM’s mission is to reveal innovative ways to use Dynamics CRM and bring the application to more businesses and organizations around the world.