function readSponsor(sponsorItemID) {
HostUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
AppWebUrl = decodeURIComponent(getQueryStringParameter("SPAppWebUrl"));
try{
var executor = new SP.RequestExecutor(AppWebUrl);
var qualifiedUrl = AppWebUrl + "/_api/SP.AppContextSite(@target)/web/lists/getbytitle('" + sponsorListName + "')/items?$filter=SponsorCode eq '" + sponsorItemID + "'&@target='" + HostUrl + "'";
executor.executeAsync(
{
url: qualifiedUrl,
method: "GET",
headers: {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
},
success: function (data) {
var jsonObject = JSON.parse(data.body);
var sponsorData = jsonObject.d.results;
if (sponsorData.length == "1")
{
// for (var i = 0; i < sponsorData.length; i++) {
var activePara = sponsorData[0].IsActive;
$('#sponsorCode').val(sponsorData[0].SponsorCode);
$('#sponsorName').val(sponsorData[0].SponsorName);
$('#sponsorAddress').val(sponsorData[0].SponsorAddress);
$('#sponsorActive').attr('checked', activePara);
$('#checkboxID').iCheck({ checkboxClass: 'icheckbox_flat-green', radioClass: 'iradio_flat-green' });
$('#primarySponsorContactName').val(sponsorData[0].PrimarySponsorContactName);
$('#primarySponsorContactNumber').val(sponsorData[0].PrimarySponsorContactNumber);
$('#primarySponsorEmail').val(sponsorData[0].PrimarySponsorEmail);
$('#secondarySponsorContactName').val(sponsorData[0].SecondarySponsorContactName);
$('#secondarySponsorContactNumber').val(sponsorData[0].SecondarySponsorContactNumber);
$('#secondarySponsorEmail').val(sponsorData[0].SecondarySponsorEmail);
var noneditableChoice = true;
if (sponsorItemID) {
ActiveAndInActive(noneditableChoice);
}
}
},
error: errorHandlerRead
}
);
}
catch (errorMsg) {
console.log(errorMsg.message);
}
function errorHandlerRead(err)
{
console.log(err.data);
}
}
No comments:
Post a Comment