Newb here trying to understand SP and how to manipulate data with REST. I have been able to POST all types of data except dates. When I try this, it doesn't do anything at all for my date column, though it updates my Status column as expected. No console errors and no changes in my date column at all. Any ideas as to what might be going on? I've read every SE question i could find and tried everything suggested but nothing seems to work. Appreciate any advice!
function updateListItem(webUrl,listTitle,listItemId,itemProperties,success,failure)
{
var listItemUri = webUrl + "/_api/web/lists/getbytitle('" + listTitle + "')/items(" + listItemId + ")";
var itemPayload = {
'__metadata': {'type': getItemTypeForListName(listTitle)}
};
for(var prop in itemProperties){
itemPayload[prop] = itemProperties[prop];
}
updateJson(listItemUri,itemPayload,success,failure);
}
$("body").on("click",".closeConfirm",function(){
var newPhase = $(this).parent().siblings(".checkText").find("input").val();
var newPhaseDate = new Date(newPhase);
var newPhaseDateJSON = newPhaseDate.toJSON();
var item = {'CompletionDate': newPhaseDateJSON,'Status': 'Ready to Close'};
var reqID = $(this).parent().parent().siblings(".requestID").text();
var reqIDnum = parseInt(reqID);
var dfd = $.Deferred();
dfd.done(updateListItem(_spPageContextInfo.webAbsoluteUrl,'MyList',reqIDnum,item,printData,logError));
dfd.resolve();
function printData()
{
alert("The date has been changed!");
}
function logError(error){
console.log(JSON.stringify(error));
}
});
Note: I've also tried posting the below variables for 'CompletionDate' (in 'item' var) but no format has done anything.
var newPhase = $(this).parent().siblings(".checkText").find("input").val();
var newPhaseDate = new Date(newPhase);