EntityGetAttributeValue Method
Updated: November 29, 2016
Applies To: Dynamics 365 (online), Dynamics 365 (on-premises), Dynamics CRM 2016, Dynamics CRM Online
Gets the value of the attribute.
Assembly: Microsoft.Xrm.Sdk (in Microsoft.Xrm.Sdk.dll)
You should only use this method for attributes you know were requested in the query that retrieved the entity. You can use Entity.Contains to check whether the entity instance includes the attribute.
When an entity instance does not include the attribute specified using the attributeLogicalName parameter this method will return null or the default value for the type rather than throw an exception. You should not assume that the entity includes the attribute. It may not be included if the code that retrieved the attribute didn’t request it.
The following table describes the default types for Dynamics Customer Engagement types which have default values:
CRM Type | .NET Type | Default Value |
Two Options | Boolean | false |
Whole Number | Int | 0 |
Floating Point Number | Double | 0.0 |
Currency | Decimal | 0 |
Date and Time | DateTime | DateTime.MinValue(01/01/0001) |
As mentioned above, getAttributeValue will return the default value rather than null for these attributes when the attribute is not requested in the query.
Microsoft Dynamics 365
© 2017 Microsoft. All rights reserved. Copyright