Invalid date/time value

Forums Classic DFFS Invalid date/time value

Viewing 1 reply thread
  • Author
    • #27152
      Brett Ross

      I’ve got some javascript that creates a new record in the list, based on data from the current record, when a check box gets checked. The script works correctly until I try to add one more field, a date field, to the fields it fills. Now, I’m getting an error message that says “A date/time field contains invalid data.” The field is a Date/Time (date only) field called “Date”. Here’s the line I added:

      data.Date = getFieldValue(“Date”);

      Here’s the whole function:

      function addItemInShiftReport(){
      var ok = spjs.dffs.check_Mandatory([“Title”]), data = {}, newItem;
      var newdate = new Date()
      data.Title = getFieldValue(“NextShiftName”);
      data.Facilities0 = getFieldValue(“Facilities0”);
      data.Shift_ = getFieldValue(“NextShift”);
      data.ShiftName_1 = getFieldValue(“NextShiftName”);
      data.Region = getFieldValue(“Region”);
      data.Facility_Shift = getFieldValue(“NextShiftName”);
      data.Superintendent1 = getFieldValue(“Superintendent1”);
      data.ADCS_1 = getFieldValue(“ADCS_1”);
      data.ADCS_2 = getFieldValue(“ADCS_2”);
      data.ADCS_3 = getFieldValue(“ADCS_3”);
      data.Supervisors_Email = getFieldValue(“Supervisors_Email”);
      data.SupervisorsEmails2 = getFieldValue(“SupervisorsEmails2”);
      data.SupervisorsEmails3 = getFieldValue(“SupervisorsEmails3”);
      data.FullShiftName = getFieldValue(“NextShiftName”)+’-‘+getFieldValue(“End_x0020_Date”);
      data.Date = getFieldValue(“Date”);
      data._vLookupID = _spPageContextInfo.userId + “:” + new Date().valueOf();
      data._DFFSID = new Date().valueOf();
      newItem = spjs.utility.addItem({“listName”:”Shift Report”,”data”:data});
      // Item added

      function PreSaveAction(){
      // If the checkbox is checked and it was not checked when the form was loaded
      if(getFieldValue(“CreateNextShiftReport”) && !spjs.dffs.beforeProperties.CreateNextShiftReport){
      return true;

    • #27167
      Alexander Bautz

      The date format must be like this:


      Change your code like this:

      data.Date = spjs.utility.getDateFieldAsDateObject("Date").toISOString();


Viewing 1 reply thread
  • You must be logged in to reply to this topic.