getDataRowFromCustomListUsingId: function (customListName, id) {
var scriptbase = hostUrl + "/_layouts/15/";
$.getScript(scriptbase + 'SP.Runtime.js',
function () {
$.getScript(scriptbase + 'SP.js',
function () {
$.getScript(scriptbase + 'SP.RequestExecutor.js', getDataById);
});
});
//Read Data From Custom List - Host Web
function getDataById() {
var context;
var factory;
var appContextSite;
var mylist;
var targetListItem;
context = new SP.ClientContext(appweburl);
factory = new SP.ProxyWebRequestExecutorFactory(appweburl);
context.set_webRequestExecutorFactory(factory);
appContextSite = new SP.AppContextSite(context, hostUrl);
this.web = appContextSite.get_web();
mylist = this.web.get_lists().getByTitle(customListName);//Custom List Name
targetListItem = mylist.getItemById(id);
context.load(targetListItem);
context.executeQueryAsync(
function () {
editsuccess(targetListItem);
},
function () {
error();
});
}
}
var scriptbase = hostUrl + "/_layouts/15/";
$.getScript(scriptbase + 'SP.Runtime.js',
function () {
$.getScript(scriptbase + 'SP.js',
function () {
$.getScript(scriptbase + 'SP.RequestExecutor.js', getDataById);
});
});
//Read Data From Custom List - Host Web
function getDataById() {
var context;
var factory;
var appContextSite;
var mylist;
var targetListItem;
context = new SP.ClientContext(appweburl);
factory = new SP.ProxyWebRequestExecutorFactory(appweburl);
context.set_webRequestExecutorFactory(factory);
appContextSite = new SP.AppContextSite(context, hostUrl);
this.web = appContextSite.get_web();
mylist = this.web.get_lists().getByTitle(customListName);//Custom List Name
targetListItem = mylist.getItemById(id);
context.load(targetListItem);
context.executeQueryAsync(
function () {
editsuccess(targetListItem);
},
function () {
error();
});
}
}
No comments:
Post a Comment