Предотвратить двойное собрание в календаре SharePoint csom

Я пытаюсь сделать это, если дата и время уже забронированы в календаре, не бронируйте, я использую этот код, и ничего не отображается? Любые предложения?

 var context = SP.ClientContext.get_current();
var web = context.get_web();
var list = web.get_lists();
var targetList;

function createItem() { targetList = list.getByTitle("AppbokningarList");

    var listItemCreation = new SP.ListItemCreationInformation();
    var newItem = targetList.addItem(listItemCreation);
    var listItemTitle = document.getElementById('Textrubrik').value;
    alert(listItemTitle);
    var listItemCustom = document.getElementById('datepicker').value;
    alert(listItemCustom);
    var listItemFromTime = document.getElementById('timepicker').value;
    alert(listItemFromTime);
    var listItemtoDate = document.getElementById('datepickerto').value;
    alert(listItemtoDate);
    var listItemToTime = document.getElementById('timepickerTo').value;
    alert(listItemToTime);
    var listItemBeskrivning = document.getElementById('Textbeskrivning').value;
    alert(listItemBeskrivning);
    newItem.set_item('Title', listItemTitle);
    var result = listItemCustom + " " + listItemFromTime;
    newItem.set_item('EventDate', result);
    var result2 = listItemtoDate + " " + listItemToTime;
    newItem.set_item('EndDate', result2);
    newItem.set_item('Description', listItemBeskrivning);

    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml("<Where><Geq><FieldRef Name='EventDate' /><Value Type='DateTime'>" + result + "</Value></Geq><Leq><FieldRef Name='EndDate' /><Value Type='DateTime'>" + result2 + "</Value></Leq><FieldRef Name='RecurrenceID' /></Where>");

    this.collListItem = targetList.getItems(camlQuery);
    context.load(collListItem);

    var property = new SP.EventProperties();
    if (collListItem > 0) {
        property.cancel = true;
    }
    newItem.update();
    context.load(newItem);

    context.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),Function.createDelegate(this, this.onQueryFailed));

}

функция onQuerySucceeded (отправитель, аргументы) {

var succeded = "Mötet är nu bokat!";
alert(succeded);

}

функция onQueryFailed (отправитель, аргументы) {

var failed = "Redan bokat!";
alert(failed);

}


person Batistuta    schedule 17.11.2014    source источник


Ответы (1)


Посмотрите на все ваши set_items. Скорее всего, ваши поля даты нуждаются в фактическом объекте даты для успешного сохранения в SP.

var currDate = new Date();
listItem.set_item('DateColumn',currDate);
listItem.update();

Интересные материалы здесь: http://alexeybbb.blogspot.com/2012/09/sharepoint15-js-update-datetime-field.html

person InvoiceGuy    schedule 18.11.2014
comment
Все сохраняется, проблема в том, что я не могу работать со своим запросом, поэтому пользователь не может добавить двойное бронирование в одно и то же время. - person Batistuta; 18.11.2014