Connect a new entity to an existing entity by using a lookup field
Published: March 10, 2006
When you create a custom entity, you typically want to add a field on other forms so that users can reference a record in the custom entity. This type of field is called a lookup field. For example, if you have a custom entity named Branch with information about branch offices, you can add a Branch lookup field on the Account form so that when users enter an account they can specify which branch office the account is associated with.
Lookup fields can only be created for looking up data from custom entities. It is not possible to create a new lookup field that looks up data from a default Microsoft CRM entity. To add a lookup field, you need the System Administrator or System Customizer security role, or equivalent privileges.
The following steps assume you have already created a custom entity named Branch.
On This Page
Create your new lookup attribute
While most types of new attributes are created in the Attributes area of an entity, lookup attributes are created automatically when you create a relationship between two entities.
There are two types of relationships you can create: many-to-one and one-to-many. Because many accounts can be associated with one branch, you’ll create a many-to-one relationship from the Account entity to the Branch entity. This is the most commonly used relationship type for a lookup because typically any number of records in the entity to which you are adding the lookup can be associated with one record in the custom entity.
1. | In Microsoft CRM Dynamics CRM 3.0, click Settings, click Customization, click Customize Entities, double-click Account, and then click Relationships. |
2. | On the Actions toolbar, click New Many-to-1 Relationship. |
3. | In the Relationship: New dialog box, in the Primary Entity box, select Branch. |
4. | In the Display Name box, type Branch. Though this is the display name for the relationship, it is also the display name of the new lookup attribute. The Type field is set to lookup. |
5. | If you want this attribute to be Business Required or Recommended, select the appropriate setting in the Requirement Level box. |
6. | In the Relationship Behavior section, in the Type of Behavior box, select Referential. |
7. | Click Save and Close. This leaves the Entity: Account form open. Keep this form open, because you will use it in the next procedure. |
Add your new lookup attribute to a form
You can position the new lookup attribute on the Account form wherever it makes most sense for your users.
1. | On the Entity: Account form, under Details, click Forms and Views, and then in the list, double-click Form. |
2. | Select the section where you want to add the Branch lookup attribute. To select a section, click the section header, and a green line is displayed surrounding the section. |
3. | Click Add Fields. Your new lookup attribute appears on the list. |
4. | Select Branch, and then click OK. |
5. | Click Save, which will leave the Form: Account form open. Keep this form open, because you will use it in the next procedure. |
Test your new lookup field
Before you publish a customization to a form, preview it in all the modes that will use the form so that you can verify that it works as you expect.
1. | On the Form: Account form, on the Preview menu, click Create Form. |
2. | Click the Lookup button next to the Branch field. If you have created any records in the Branch entity, the list appears. Close the Lookup Records dialog box, and then, on the File menu, click Close to close the preview window. |
3. | On the Form: Account form, on the Preview menu, click Update Form, and then repeat step 2. |
4. | Click Save and Close. |
5. | On the Entity: Account form, click Save and Close. |
Publish your customization
For your users to see the changes you’ve made, you must publish the customization.
| • | On the Customize Entities page, on the Actions toolbar, click Publish. |
Remember to let your users know about the new field and how to use it.