When you update an entity instance there is a mechanism you can use to differentiate the absence of a value from a null value. To set an attribute value to null you must set both IsNull and IsNullSpecified to true. For attributes of type String, you must assign the value to String.Empty. This same mechanism is used when you create a query to find a null value.
Another option is to use the type helper code available in Microsoft.Crm.Sdk assembly and in the CRMHelpers classes.
Example
The following code example shows you how to create null instances of the various Microsoft Dynamics CRM attribute types.
CrmBoolean boolean = new CrmBoolean();
boolean.IsNull = true;
boolean.IsNullSpecified = true;
CrmDecimal dec = new CrmDecimal();
dec.IsNull = true;
dec.IsNullSpecified = true;
CrmFloat f = new CrmFloat();
f.IsNull = true;
f.IsNullSpecified = true;
CrmMoney money = new CrmMoney();
money.IsNull = true;
money.IsNullSpecified = true;
CrmNumber number = new CrmNumber();
number.IsNull = true;
number.IsNullSpecified = true;
Lookup lookup = new Lookup();
lookup.IsNull = true;
lookup.IsNullSpecified = true;
PickList list = new PickList();
list.IsNull = true;
list.IsNullSpecified = true;
Status status = new StatusV();
status.IsNull = true;
status.IsNullSpecified = true;
Owner owner = new Owner();
owner.IsNull = true;
owner.IsNullSpecified = true;
Example
The following code example shows you how to create null instances of the various Microsoft Dynamics CRM attribute types using the type helper classes.
CrmBoolean boolean = CrmBoolean.Null;
CrmDecimal dec = CrmDecimal.Null;
CrmFloat flt = CrmFloat.Null;
CrmMoney money = CrmMoney.Null;
CrmNumber number = CrmNumber.Null;
Lookup lookup = Lookup.Null;
Picklist list = Picklist.Null;
Status status = Status.Null;
Owner owner = Owner.Null;
1 comment:
Helps...tx
Post a Comment