Skip to content


How do I write a NULL value into CRM 2011 whole number field?

John asked 10 years ago
I am trying to map a SQL INT field that contains a NULL into a CRM 2011 field setup as a whole number in a custom entity but I am getting an error stating: Object cannot be cast from DBNull to other types.  How can I write a NULL into a CRM whole number field if the SQL field is a NULL?  My SmartConnect map has the Data Source of MSSQL table and the destination is a CRM 2011 custom entity.   Thanks.
Best Answer
Ruaan Jonker answered 9 years ago
Hi John

What you can do is create a calculated field to check the integer value of the data source and return whatever number you would like to return.
Then map the calculated field to the destination field in CRM.

if (_MYINT = System.Int32.MinValue) then
     return 0
     return _MYINT
end if

if (_MYINT == System.Int32.MinValue)
     return 0;
     return _MYINT;

John replied 9 years ago

Thanks Ruaan for your reply,

Instead of returning a number to the destination field is it possible to fill the destination field with a NULL like when I enter a record from the CRM front end? 

Thanks for your help.


Manny replied 6 years ago

I’m trying to insert a null value to CRM as well. Was this ever fixed?

If you would like to submit an answer or comment, please sign in to the eOne portal.