Microsoft Dynamics CRM – Changing the Primary Field in Custom Entities

Editor's Note: The following MVP Monday post is by Dynamics CRM MVP Jerry Weinstock.

When you create a custom entity (think table for all you DB gurus) in Dynamics CRM if you do not think before you click you will end up with a Primary Field that is Required.

What you normally get is the configuration shown in this screen shot of a default setup.

This may not fit some environments where you:

  1. Do not want it to be required.
  2. Would like it to be something else than a free form text field.
  3. Want to rename it from the generic “Name” to something more meaningful.

Unfortunately, there are no other field types available – you are limited to Text, you can change the Display Name and the Requirement Level. However, once you save the record the settings cannot be edited.

The following is a how-to using a client example on moving from the default configuration to a customized configuration. The client needed a CRM entity to track what types of technology an Account was using. They wanted to enforce the name of the technology the CRM user would enter into the Primary Field, which is utilized throughout CRM for Lookups, etc.

We created a new entity called Technology, renamed the Primary Field to ‘Technology’ and made the Requirement Level ‘No Constraint’.

We then created a new field called Technology Type as an Option Set and entered the option values.

Then we created a Workflow Rule that would fill in the Primary Field (Technology) with the value from the Option Set. That way the client could easily enforce consistency in the Primary Field. The workflow rule was set to start when the record was initially created or if the option set value changed.

After the Workflow Rule was created, published and tested we went back to the Technology form and made the Primary Field Read Only.

The nice thing about using Workflow to support this work around is that it is a technique that programmers or non-programmers can use. Yes, you could use Jscript to populate the value as soon as the Option Set Value is selected or changed but Workflow removes one less piece of code to manage and document. In addition, it further demonstrates the power of Dynamics CRM Workflow, which some other competitors do not have in their feature set.

Author's Bio

  Jerry Weinstock is the Business Development Manager at CRM Innovation. Jerry has been working with CRM since the 1.2 release in 2003. CRM Innovation builds Email, Marketing and Event Management solutions for Microsoft Dynamics CRM. Twitter: @crminnovation

MVP Mondays

The MVP Monday Series is created by Melissa Travers. In this series we work to provide readers with a guest post from an MVP every Monday. Melissa is a Community Program Manager for Dynamics, Excel, Office 365, Platforms and SharePoint in the United States. She has been working with MVPs since her early days as Microsoft Exchange Support Engineer when MVPs would answer all the questions in the old newsgroups before she could get to them.

Comments (4)

  1. says:

    Very helpul. We will be using this in our CRM environment.

  2. Leon Tribe says:

    An excellent workaround. One small correction. You can change the requirement level and display name of the field, post-save, by going to it in the field list of the entity 😉

  3. Jordi says:

    Good post,

    Like Leon Tribe said, you can edit the field length properties and the required attribute by going to the list of fields of the entity.

    If you still need to actually change the value to be the one from a different field, then, yes you can do it through a workflow (with the drawback that will update the value asynchronously), or through a sync plugin (or sync workflow in Dynamics CRM 2013-2015).

    The thing is that if you have some many dependencies against the previous primary field you will need to update those as well (I mean, something like Email Templates, other workflows, other plugins, potentially web applications etc).

    I had to change the primary field for an entity that was created like one year ago, and didn't want to spend like more than one week in regression testing so the only feasible option that I found was this one (unsupported though):…/change-primary-field-entity-created.html

    Btw, I still can't believe why is this not part of the out of the box CRM 🙂

  4. ArunKumarS says:

    In Whats new section of Posts,
    For a company that i create, has Account : Created By xxxxx rather than Company: Created By xxxxx,
    that is, the Entity Name field is being used rather than the Display name.
    Could you please let me knwo how to go about this ?
    I did try changing the messages of Company entity, but still doesnt get it working.

Skip to main content