How can I set a field to null in a Pre-Update Plugin
Posted
by
Juergen
on Stack Overflow
See other posts from Stack Overflow
or by Juergen
Published on 2012-05-30T12:20:09Z
Indexed on
2012/06/11
4:40 UTC
Read the original article
Hit count: 304
dynamics-crm
|dynamics-crm-2011
I developed a Pre-Update Plugin for the Case entity. In this plugin I want to set a string field to a new value. It works smoothly if the new value is not null. But if the new value si null, it is just ignored.
This works:
Incident caseTarget = ((Entity) localContext.PluginExecutionContext.InputParameters["Target"]).ToEntity<Incident>();
caseTarget.ProductSerialNumber = "new value";
After the execution of the plugin, the ProductSerialNumber field has value "new value".
This doesn't work:
Incident caseTarget = ((Entity) localContext.PluginExecutionContext.InputParameters["Target"]).ToEntity<Incident>();
caseTarget.ProductSerialNumber = null;
After the execution of the plugin, the ProductSerialNumber field has still its old value.
How can I set the target's field to null?
© Stack Overflow or respective owner