• 0
  • 114
  • 7.8k

inserting date into sharepoint hosted list using JSOM

Aug 22 2016 7:21 AM
how to save Date into SharePoint hosted app list?am here trying to create app in which i need to save date into calendar list using JSOM but am enable to do that,can any one help me?my code is as below
function bookingRoomForMeeting() 
var ctx = new SP.ClientContext(appWebUrl);
  var list = ctx.get_web().get_lists().getByTitle("MyCalendarList"); //Get the List based upon the Title
var listCreationInformation = new SP.ListItemCreationInformation(); //Object for creating Item in the 
ListlistItem = list.addItem(listCreationInformation);
listItem.set_item('Title', $("#txt_Title").val());
var date = $("#txt_startTime").val();
var dateTime = moment(date, 'DD/MM/YYYY HH:mm a').format("MM/DD/YYYY HH:mm a");
listItem.set_item('EventDate', dateTime);
var enddate = $("#txt_endTime").val();
var enddateTime = moment(enddate, 'DD/MM/YYYY HH:mm a').format("MM/DD/YYYY HH:mm a");
listItem.set_item('EndDate', enddateTime);
listItem.set_item('EmailId1', $("#txt_EmailId1").val());
listItem.set_item('EmailId2', $("#txt_EmailId2").val());
ctx.executeQueryAsync(Function.createDelegate(this, success),Function.createDelegate(this, fail));
function success() 

function fail() 
alert("operation failed");


Answers (2)