Data Validation and Default Values
[Applies to: Microsoft Dynamics CRM 4.0]
Find the latest SDK documentation: CRM 2015 SDK
In earlier versions of Microsoft Dynamics CRM, much of the data validation was done at the application level. If you created an entity instance using the SDK, some data types were not validated. Similarly, if a default value was specified for an attribute, the default was not set when you created an entity instance using the SDK. Microsoft Dynamics CRM adds data validation and default value support at the SDK level. This validation occurs before any other execution pipeline operations, that is before any pre-create plug-ins are invoked.
Note that this feature only applies to the 2007 endpoint. SDK calls made using the 2006 endpoint are not subject to data validation or default value support.
The following table shows the supported data validation for each attribute type.
|Attribute type||Class name||Validation support|
|Boolean||CrmBoolean||Validation of option value|
|Text or memo||String||Maximum string length|
|Integer or number||CrmNumber||Minimum and maximum values|
|Numeric or money||CrmDecimal||Minimum and maximum values
Precision1 (number of decimal places)
|Picklist||Picklist||Validation of option value|
|State and Status||Status
|Validation of option value|
1 All validation errors other than precision result in throwing an error. For precision, the value is rounded up. For example, assuming the precision is 2, a value set to 11.3456 will be rounded to 11.35 when the record is saved.
When you create an entity instance using the Create method or the Create message, you supply an instance of the entity class that contains the values for the new entity instance. If you leave any of the properties null, the system will fill in the default values if a default is specified in the metadata for the attribute.
If you set the IsNullSpecified property to true, default values will not be applied. For more information about how to set null values, see Assigning Null Values.
© 2010 Microsoft Corporation. All rights reserved.