function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SimrinSimrin 

setting blank value to date field

Hello,

I have a custom field TEXT__C   Date.
I set some date. its ok untill now.

From the backed i want to reset the date.
TEXT__C  =null; //no error but numm is displyed
 TEXT__C  =' '; //error saying string value cannot be set to date.

i want to set blank value to the date
Best Answer chosen by Simrin
sandeep sankhlasandeep sankhla
Hi Simirin,

You have only 2 options to set in this case..

1. Any date
2. Null

You can not assign anything except above 2 to a date type field..

Thanks,
Sandeep

All Answers

lakshman169lakshman169
Hello,

single quote'('') represent a string so you can't set like TEXT__C  ='';, you should set TEXT__C  =null;
sandeep sankhlasandeep sankhla
Hi Simirin,

You have only 2 options to set in this case..

1. Any date
2. Null

You can not assign anything except above 2 to a date type field..

Thanks,
Sandeep
This was selected as the best answer
Nitin PaliwalNitin Paliwal
HI Simrin,
You can use Text__c = null;

Its working fine for me no null is displayed.

Thanks
Nitin
AOPS GroupAOPS Group
I am having a similar issue. I am using salesforce-python-toolkit. Python doesn't have a null. Instead it has None value. If I set the field to None and trying calling the API, the field is not set to blank. The field still retains the original field. Please assist.
damonsterdamonster
Instead of setting TEXT__C  =null;

try:

AccountObj.fieldsToNull = new String[] { "TEXT__c" };

I was struggling with this same issue until using the fieldsToNull