How can I set a field to null in a Pre-Update Plugin
- by Juergen
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?