开发者

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

开发者 https://www.devze.com 2023-01-15 08:07 出处:网络
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 d

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_associat开发者_运维问答epastorid.type = EntityName.contact.ToString();
house.new_associatepastorid.value = Guid.Empty;

Does not work.


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.


I found the answer in the SDK. You have to set the isnull value = true, as well as set the isnullspecified = true. You also need to not set the type or the value fields. So the code would be:

house.new_associatepastorid = new HLCImport.CrmSdk.Lookup();
house.new_associatepastorid.IsNullSpecified = true;
house.new_associatepastorid.IsNull = true;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号