1

I am trying to set date field to allow null values on my insert form but every method I have tried comes back with " cannot insert null values". I simply want to allow users the option to insert a date or not. I am using Sharepoint 2013 and javascript.

I read on https://msdn.microsoft.com/en-us/library/office/jj245356.aspx to use CSOM null - but there is no example and I am very new to sharepoint. I dont want to use min.value || new date(0).

   if (DateField == "")
    {
       DateField = new Date(0); // this is the closest I have got but need this to be empty
       oListItem.set_item('DateField ', DateField);
    }
3
  • have u tried adding item to list and not setting any value for date field? like setting Title and not setting date field... Commented Apr 5, 2016 at 12:30
  • 1
    Is the date field requiered in list settings? Commented Apr 5, 2016 at 12:46
  • Nope, it just wont allow an empty string or null value. I have found a work around to this issue and will upload solution in a mo.
    – Shell
    Commented Apr 6, 2016 at 9:43

2 Answers 2

1

Even i also had the same issue a month ago, and i researched on Internet but didn't found a proper solution.

So as most of the blogs written, it says that the date column cannot be left blank. Now if you want to show date column on your form, use Jquery and bind that with the text box in the list column. That is the only workaround that i see, In case you found some, pls do share.

Thanks :)

0

To work around the issue I simply added an if statement to stop the insert if the date field is empty i.e.

if(Date != "")oListItem.set_item('Date', covertToAmericanFormat(Date));

I hope this helps others as it is a real pain passing null dates!! The insert will only work if there is a date present in the textbox otherwise it will not insert. Problem resolved :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.