Set nullable types in Dynamics 365 & C#


A little code snippet demonstrating how to set nullable types in Microsoft Dynamics 365 CE.

The code

// Set a Two Options to null
bool? nullOption = null;
entity["myoption"] = nullOption;

// Set int to null
int? nullNumber = null;
entity["mynumber"] = nullNumber;

// Set OptionSetValue to Null
OptionSetValue myNullOption = new OptionSetValue();
myNullOption = null;
entity["new_optionset"] = myNullOption;

Leave a comment