Home › Forums › Classic DFFS › Invalid date/time value
- This topic has 1 reply, 2 voices, and was last updated 5 years, 1 month ago by Alexander Bautz.
-
AuthorPosts
-
-
September 24, 2019 at 13:52 #27152
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()
if(ok){
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});
if(newItem.success){
// Item added
}else{
alert(newItem.errorText);
}
}
}function PreSaveAction(){
// If the checkbox is checked and it was not checked when the form was loaded
if(getFieldValue(“CreateNextShiftReport”) && !spjs.dffs.beforeProperties.CreateNextShiftReport){
addItemInShiftReport();
}
return true;
} -
September 24, 2019 at 17:32 #27167
Hi,
The date format must be like this:"2019-12-24T07:00:00.000Z"
Change your code like this:
data.Date = spjs.utility.getDateFieldAsDateObject("Date").toISOString();
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.