I have a column [ScheduleTime] which is a DateTime
type in my List. Using JavaScript i need to update the [ScheduleTime] column which should be Current Day whenever my script loads. But here I need to update [ScheduleTime] column's Date only. Time should remain same. I am gonna use set_item
function.
Please help me out on this.
var collListItem;
ExecuteOrDelayUntilScriptLoaded(retrieveListItems, "sp.js");
function retrieveListItems() {
sucess();
var clientContext = new SP.ClientContext(siteUrl);
var oList = clientContext.get_web().get_lists().getByTitle('Master Task Summary');
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml("<View><Query><Where><Geq><FieldRef Name='ScheduleTime'/><Value IncludeTimeValue='true' Type='DateTime'><Today /></Value></Geq></Where></Query><RowLimit>10</RowLimit></View>");
this.collListItem = oList.getItems(camlQuery);
clientContext.load(collListItem);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function sucess()
{
var clientContext1 = new SP.ClientContext(siteUrl);
var oList1 = clientContext1.get_web().get_lists().getByTitle('Master Task Summary');
var varlist= oList1.getItemById(86);
alert("1st");
var scheduleTime = new Date(varlist["ScheduleTime"]);
alert("2st");
var today = new Date();
var newScheduledTime = new Date(today.getFullYear(), today.getMonth(), today.getDate(), scheduleTime.getHours(), scheduleTime.getMinutes(), scheduleTime.getSeconds(), scheduleTime.getMilliseconds());
alert("3st");
varlist.set_item('ScheduleTime', newScheduledTime);
alert("4th");
varlist.update();
alert("5th");
clientContext1.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceed), Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceed()
{
alert("Update USccess");
}