Search code examples
dynamics-crmdynamics-crm-4

How does one set a lookup value to blank or null in MSCRM?


When setting a Lookup value in CRM everything works fine if you don't want to change anything, or if you want to set it to a new value. However, when you want to UNSET the current value, the way to do so is unclear.

For example,

house.new_associatepastorid = new HLCImport.CrmSdk.Lookup();
house.new_associatepastorid.type = EntityName.contact.ToString();
house.new_associatepastorid.value = Guid.Empty;

Does not work.


Solution

  • Setting the IsNull and IsNullSpecified properties is absolutely fine. For simpler code, all of the standard types has a static member named Null. So in this case you could have used Lookup.Null.