Hosk CRM Dev Tip – add ID suffix to lookup fields

I got reminded of this best practice twice recently.

Once by a fellow developer and then I also came across these advise whilst studying for the MB2-703 – CRM 2013 customization and configuration exam.

The advice is when you create a field of type lookup then you should add an ID suffix to the field e.g.

Primary Contact

primarycontactid

primarycontactID

Why should you do this?

The reason is it makes it obvious the field is a lookup and not a text, optionset or integer.  below the screenshot shows you how it makes the lookup easy to spot

primarycontactID 1

When a developer is writing some code then lookup fields are usually EntityReference fields and these have a few different values

Entity Logical name

Guid

 

When the developer see’s the ID suffix they will know it’s a lookup and the ID will remind them it basically the guid of a record and they can use this field to retrieve the other fields.

Common Code

Another reason for using this naming system, Microsoft do this so it will mean your fields are similar to Microsoft and as it’s a best practice when you work on other projects with different developers they will hopefully do this as well.

 

4 thoughts on “Hosk CRM Dev Tip – add ID suffix to lookup fields

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.