Wednesday, 18 April 2018

Room Availability validation in list


Below method will return true or false

false means room is already booked

true means room is available

var validationflag=CheckAvailabbleRooms("4/30/2018 1:10 AM", "4/30/2018 2:10 AM", "room1");


function CheckAvailabbleRooms(startdatea, endates, roomss)
{

    var val_flag = true;
    var companySiteUrlLink = titanForWork.getQueryStringParameter("CompanySiteUrl");
    var startdateaes = new Date(startdatea);
    var tStart = startdateaes.toISOString();
    var endatestv = new Date(endates);
    var vEnd = endatestv.toISOString();//EndDate
    var filterData = "&$filter=EndDate ge datetime'" + tStart + "' and Rooms eq '" + roomss + "'";
    var listName = 'ListName';
    var siteURL = companySiteUrlLink + "/_api/web/lists/getbytitle('" + listName + "')/items?$select=ID,Title,Rooms,Location,EventDate,EndDate" + filterData;
    console.log(siteURL);
    $.ajax({
        url: siteURL,
        headers: { Accept: "application/json;odata=verbose" },
        async: false,
        success: function (data) {
            var items = data.d.results;
            // alert(items.length);
            for (var index = 0; index < items.length ; index++) {
                if (items[index].EventDate <= vEnd) {
                    val_flag = false;
                    var uuu = new Date(items[index].EventDate);
                    console.log(items[index].ID + "-------" + uuu);
                }
            }
        }, eror: function (data) {
            console.log($('#txtSomethingWentWrong').val());
        }
    });
    return val_flag;
}

Sunday, 8 April 2018

Onedrive Documents using rest api





Get all shared documents with me on onedrive  end point url


https://office365domainname-my.sharepoint.com/_api/v2.0/drive/oneDrive.sharedWithMe








Get all my ondrive documents



https://office365domain-my.sharepoint.com/personal/username_YourO365DomainHere_onmicrosoft_com/_api/Web/GetFolderByServerRelativeUrl('/personal/username_YourO365DomainHere_onmicrosoft_com/Documents')?$select=Files/Name&$expand=Files