Reputation: 963
I'm trying to convert a crm 4 Plug-in to CRM 2011. Does anybody know which are respective types in CRm 2011?
Customer, CrmDateTime, CrmDecimal, CrmFloat, CBoolean, CrmMoney, Owner, Picklist, Key, Status, UniqueIdentifier, CrmBoolean
public static object GetAttributeValue(this Entity target, string attributeLogicalName)
{
object value;
if (target.Attributes.Contains(attributeLogicalName))
{
value = target.Attributes[attributeLogicalName];
if ((value is Boolean) || (value is string))
return value;
else if (value is Customer)
return ((Customer)value).Value;
else if (value is CrmDateTime)
return ((CrmDateTime)value).UserTime;
else if (value is CrmDecimal)
return ((CrmDecimal)value).Value;
else if (value is CrmFloat)
return ((CrmFloat)value).Value;
else if (value is CrmNumber)
return ((CrmNumber)value).Value;
else if (value is CBoolean)
return ((CrmBoolean)value).Value;
else if (value is Lookup)
return ((Lookup)value).Value;
else if (value is CrmMoney)
return ((CrmMoney)value).Value;
else if (value is Owner)
return ((Owner)value).Value;
else if (value is Picklist)
return ((Picklist)value).Value;
else if (value is Key)
return ((Key)value).Value;
else if (value is Status)
return ((Status)value).Value;
else if (value is UniqueIdentifier)
return ((UniqueIdentifier)value).Value;
else if (value is CrmBoolean)
return ((CrmBoolean)value).Value;
return null;
}
else
return null;
}
Upvotes: 2
Views: 1464
Reputation: 10344
Since Dynamics CRM 2011 there is no need for custom types as a replacement for .NET types anymore. You could (and have to) use the standard .NET types. See Types in the Microsoft Dynamics CRM SDK for a description of the type mapping.
The existence of custom types in CRM 3 and CRM 4 (CrmBoolean
, ...) was necessary as CRM 3 was based on .NET 1 which had no Nullable Types.
Upvotes: 5
Reputation: 7224
Please see this article that documents the mapping from CRM 4 types to CRM 2011 types.
It is not entirely true that custom types are no longer required. While most custom types are no longer used they are still required for attributes that are lookups and picklists.
Upvotes: 0