Hello,
I have this plugin code for CRM 4 which checks if field is null or empty:
public static bool CrmNullOrEmpty<T>(T attribute) where T : class
{
bool isNull = true;
if (attribute!= null)
{
if (attribute is CrmDateTime )
{
CrmDateTime crmDateTime = attribute as CrmDateTime;
isNull = crmDateTime.IsNull || crmDateTime.IsNullSpecified;
}
else if (attribute is Picklist)
{
Picklist sPicklist = attribute as Picklist;
isNull = sPicklist.IsNull || sPicklist.IsNullSpecified;
}
else if (attribute is Key)
{
Key key= attribute as Key;
isNull = key.Value == Guid.Empty;
}
.....//all other types
}
return isNull;
}
Plugin
EntityReference primarycontact = (EntityReference)entity["primarycontactid"];
if (!CrmNullOrEmpty(primarycontact))
//do something
How would you do this in CRM 2011?
Thank you.
*This post is locked for comments
I have the same question (0)