SharePoint Hosted App Get Data from Host Web
We cant get the List data with is available on SharePoint Hosted Web.
The Current context of the App and Hosted web is different. So, we cant get Web context directly.
we can get the Hosted Web Context as below.
var hostcontext;
var web;
var lists;
var collListItem = '';
var hostUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
currentcontext = new SP.ClientContext.get_current();
hostcontext = new SP.AppContextSite(currentcontext, hostUrl);
web = hostcontext.get_web();
var oList = web.get_lists().getByTitle('MyNotes');
We cant get the List data with is available on SharePoint Hosted Web.
The Current context of the App and Hosted web is different. So, we cant get Web context directly.
we can get the Hosted Web Context as below.
var hostcontext;
var web;
var lists;
var collListItem = '';
var hostUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
currentcontext = new SP.ClientContext.get_current();
hostcontext = new SP.AppContextSite(currentcontext, hostUrl);
web = hostcontext.get_web();
var oList = web.get_lists().getByTitle('MyNotes');
0 comments: