Dynamics 365 - Set Null Value For All Data Types Using C#


Recently we had a requirement to set null value for all data types field from C# as part of our integration.

I tried searching on the internet but couldn't find proper documentation or sample code for all data types field. So I decided to try using console utility and also wanted to share with CRM communities.

Sample Code Snippet

Entity objLead = new Entity("lead");
objLead.Id = Guid.Parse("Record GUID");
//objLead["ims_loanamount"] = null;
//objLead["ims_loanrate"] = null;
//objLead["ims_birthday"] = null;
//objLead["ims_gender"] = null;
//objLead["ims_creditscore"] = null;
//objLead["ims_loantype"] = null;
//Two Optionset
//objLead["ims_firsttimebuyer"] = null;


I have provided sample code to set value to different data types from C# code for Dynamics CRM.

Hope this helps!

Happy CRMing!