This post is one of a series I am creating aimed at helping people prepare for the MB2-712 certification. (Microsoft Dynamics CRM 2016 Customization and Configuration)
In this post I am going to look at fields. A subject which hopefully follows on nicely from my last post about entities. As after you have created an entity logically the next thing you’d want to do is create the fields which makeup the entity.
Fields are sometimes described as attributes by developers, therefore the two terms are interchangeable.
- Fields are used to store values of defined types. (For example a piece of text or a date.)
- Sometimes fields of the same type can have different formats. (For example, a text field can be optionally formatted as an email address, URL, phone number etc.)
- Fields appear as controls on forms. (Such as a text box, date picker, radio buttons etc.)
- Fields can also be shown in user and system views and can be used as part of queries. (Advanced Finds.)
- For each field a column is created in the SQL table for the entity.
- Fields can be “simple” or calculated.
- Fields can be created that contain rolled up values from related entities.
As discussed already we have system and custom entities. The system entities will already comprise of many out of the box fields but we can add more custom fields as required. Although it is always a good idea to check a suitable system field doesn’t already exist before creating a custom one.
When a custom entity is first created some field will get created by default. Including things like the primary field, created on, created by, owner and many more. I doubt you will need to know exactly what these fields are but even so it is worth creating a custom entity and before adding your own custom fields have a look. Below you can see that I have done just that. With a user / team owned entity I have 19 fields before I start adding any custom ones. Notice that only two are prefixed new_. I have used the default publisher which adds new_ to all custom fields. The two fields that are created are name (the primary field for this entity) and id. (Which holds the GUID which is the primary key.)
The table below lists the standard field types available in CRM 2016.
|CRM Field Type||SQL Data Type||Details||Size|
|Single line of text||Nvarchar(n)||Single “short” lines of text. With a maximum size of 4000 characters. (n)||2 bytes x number of characters|
|Multiple lines of text||Nvarchar(?)||A text field whose content can be displayed over more than one line. Can hold up to 100,000 characters.||2 bytes x number of characters|
|Option Set||int||Options sets are picklists that are stored as an integer value. The value relates to an associated label. The labels / values can be specific to a field or global.||4 bytes|
|Two Options||bit||Boolean field with 0 or 1 values. Can be used to display yes/no true/false or any two values.||Up to 1 byte|
|Image||uniqueidentifier||Actually contains a foreign key value (GUID) that will link to an image record.
Note: Each entity only has one image. Typically used for a headshot of a contact or a logo of an account etc.
|Whole number||int||Holds an integer value from -2,147,483,648 to 2,147,483,647||4 Bytes|
|Floating Point Number||Float||Numbers with up to 5 decimal places. -100,000,000,000 to + 100,000,000,000||8 Bytes|
|Decimal Number||Decimal||Numbers with up to 10 decimal places. -100,000,000,000 to + 100,000,000,000||13 Bytes|
|Currency||Money||A number representing a currency value with up to 4 decimal places. -922,337,203,685,477 to +922,337,203,685,477
Note: To have a currency field on an entity you will also always have a currency field.
|Date and time||Datetime||Stored internally as Universal Time Coordinated (UTC) date and time. Displayed in local format.||8 Bytes|
|Lookup||uniqueidentifier||A GUID value that links to a specific entity.||16 Bytes|
|Customer||uniqueidentifier||A GUID value that links to either an account or a contact.||16 Bytes|
The field type of customer has been added at CRM 2016 Update 1. This is a special type that allows a lookup field to be created that can be either a contact or an account. Being new it is unlikely to be covered in the MB2-712 exam. (yet.) But you should ideally still be aware of this additional data type and how it operates.
Creating / Maintaining Fields
When we create a field the screen looks like this;
The table below covers the detail of each field, as always I strongly recommend you experiment with creating different types of fields;
|Field Requirement||Three options exist;
|Searchable||Yes/no field. Entering no here means the field will not show as a filter field in advanced find.|
|Field Security||Fields that are available for field security will need to be enabled here. Not forgetting a Field Security profile will need to also be defined.|
|Auditing||Setting this field to enabled will enable auditing on this field. (Assuming auditing is also enabled for the organisation and entity.)
For the exam it is worth being aware that auditing needs to be enabled at an organization, entity and field level.
|Description||A multi-line description of the field. This information will show as a “tip” when you hover the mouse over the field name in a form.|
|Appears in global filter in interactive experience||This option only applies if the entity is enabled for use in the Interactive service hub(ISH). With the ISH you can filter dashboards globally by one field from an entity. For example, you might wish to be able to filter cases by the date they were created.|
|Sortable in interactive experience dashboard||This option only applies if the entity is enabled for use in the Interactive service hub(ISH). Like the global filter this defines how data will be sorted within the ISH. For example, cases may commonly be sorted by their modified on date.|
|Data Type||As already mentioned each field will have a data type. This can’t be changed once created. Data types include Single Line of Text, DateTime, OptionSet etc.|
|Field Type||Can be simple (the default) or calculated. If calculated, you will need to save the new field and then the criteria for calculation can be defined.
Note: I will cover calculated and rolled up fields in greater detail in a later post.
|Format||Some fields types can have different formats. For example, a date field can be displayed as date time or just date.
Regardless of the format the underling data is always stored in a common format.
|Maximum length||Some fields, such as text boxes can have their length controlled.|
|IME Mode||IME mode is used to enable entry of complex characters and symbols, such as Japanese Kanji characters.
Options include Auto (the default), Inactive, Active and Disabled.
|Precision||For some numeric value types, include currency, float and decimal the precision can be defined.
Note: For currency the default precision is “Currency Prevision” meaning the system default would be used.
|Minimum and Maximum value||Some numeric values will have a max and min value. Currency fields, for example can theoretically have a range from -922,337,203,685,477.0000 to 922,337,203,685,477.0000. You may change this to limit the valid values.
For example, if you had a currency value to hold someone’s salary the min value might be 0. (People tend to not earn less than nothing!) and the max might be 1,000,000. (I don’t know many people that earn more than this, although I guess they exist!)
|OPTION SETS||If you select the field type as being an option set several additional “options” become available. Including giving the ability to select a global option set or define option values specific to this field. Plus, you can select a default value.
FYI : I will cover option sets in greater detail in a future post.
|TWO OPTIONS||Two options data types show fields to allow you to define the two possible options and the default. Initially the options will show as No and Yes. But could be changes to “Approved/Unapproved”, “True/False” or anything.
In background a two option field always has a numeric value to 0 or 1.
|Behaviour (Date and Time)||For date time files you can select a behaviour. Options include “Use Local”, “Date Only” and “Time-Zone Independent”.
When the behaviour of a field is “User Local,” field values are displayed in the user’s local time.
When the behaviour of a field is “Date Only,” field values are displayed with no time zone conversion. The date portion of the value is stored and retrieved as specified in the UI and SDK. The time portion of the value will always be 12:00 A.M. The behaviour of this field can’t be changed once it’s saved. (Tip:
When the behaviour of a field is “Time-Zone Independent,” field values are displayed with no time zone conversion. The date and time values are stored and retrieved as specified in the UI and SDK. The behaviour of this field can’t be changed once it’s saved.
|LOOKUP and Customer||If the data type is a lookup you can enter the target record type and relationship name.
The relationship name will be defaulted but you can change if required.
Customer works in a similar manner to lookup but two relationship names are given, one for account and one for contact.
When we create a lookup field a relationship between the current entity and the lookup entity is automatically created. Making the process of creating a relationship for a lookup really simple.
I have covered a lot of detail in these revision notes! Taking time to get some hands on experience of creating fields is really important.
Despite covering a lot of detail about field there is more to come! In future posts I will expand on the details here to cover calculated fields, rolled up field, option sets etc etc.
I hope this post will have helped anyone preparing for the MB2-712 certification.