'use strict';
var context;
var user;
var hostweburl;
var appweburl;
var ListName;
// This code runs when the DOM is ready and creates a context object which is needed to use the SharePoint object model
$(document).ready(function () {
getListItem();
});
// This function prepares, loads, and then executes a SharePoint query to get the current users information
function getListItem() {
hostweburl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));
ListName = decodeURIComponent(getQueryStringParameter('ListName'));
var scriptbase = hostweburl + '/_layouts/15/';
//Call method after loading required JS files from Host Web
$.getScript(scriptbase + 'SP.Runtime.js',
function () {
$.getScript(scriptbase + 'SP.js',
function () { $.getScript(scriptbase + 'SP.RequestExecutor.js', getItem); }
);
}
);
}
//Fetching List Item
function getItem() {
/* var context = SP.ClientContext.get_current();
var user = context.get_web().get_currentUser();*/
debugger;
$.ajax({
url: appweburl + "/_api/SP.AppContextSite(@target)/web/lists/getbyTitle('"+ ListName + "')/Items?@target='" + hostweburl + "'",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (data) {
var result = data.d.results;
var item="";
for (var i = 0; i < result.length; i++) {
item += "<span>" + result[i].dept + "</span>";
item += "<span>" + result[i].TRS + "</span>";
item += "<span>" + result[i].PTD + "</span>";
}
$(".DetailsItem").html(item)
},
error: function (data) {
failure(data);
}
});
}
//Get query string parameters
function getQueryStringParameter(paramToRetrieve) {
var params = document.URL.split("?")[1].split("&");
var strParams = "";
for (var i = 0; i < params.length; i = i + 1) {
var singleParam = params[i].split("=");
if (singleParam[0] == paramToRetrieve) return singleParam[1];
}
}
var context;
var user;
var hostweburl;
var appweburl;
var ListName;
// This code runs when the DOM is ready and creates a context object which is needed to use the SharePoint object model
$(document).ready(function () {
getListItem();
});
// This function prepares, loads, and then executes a SharePoint query to get the current users information
function getListItem() {
hostweburl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));
ListName = decodeURIComponent(getQueryStringParameter('ListName'));
var scriptbase = hostweburl + '/_layouts/15/';
//Call method after loading required JS files from Host Web
$.getScript(scriptbase + 'SP.Runtime.js',
function () {
$.getScript(scriptbase + 'SP.js',
function () { $.getScript(scriptbase + 'SP.RequestExecutor.js', getItem); }
);
}
);
}
//Fetching List Item
function getItem() {
/* var context = SP.ClientContext.get_current();
var user = context.get_web().get_currentUser();*/
debugger;
$.ajax({
url: appweburl + "/_api/SP.AppContextSite(@target)/web/lists/getbyTitle('"+ ListName + "')/Items?@target='" + hostweburl + "'",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (data) {
var result = data.d.results;
var item="";
for (var i = 0; i < result.length; i++) {
item += "<span>" + result[i].dept + "</span>";
item += "<span>" + result[i].TRS + "</span>";
item += "<span>" + result[i].PTD + "</span>";
}
$(".DetailsItem").html(item)
},
error: function (data) {
failure(data);
}
});
}
//Get query string parameters
function getQueryStringParameter(paramToRetrieve) {
var params = document.URL.split("?")[1].split("&");
var strParams = "";
for (var i = 0; i < params.length; i = i + 1) {
var singleParam = params[i].split("=");
if (singleParam[0] == paramToRetrieve) return singleParam[1];
}
}