We can check whether a list exists in host web for the app web. This can be done by REST call to the Host web from App Web. The below code samples illustrates the scenario:
function isListExist(listName, onExist, onNotExist) {
var executor;
executor = new SP.RequestExecutor(appweburl);
executor.executeAsync({
url: appweburl + "/_api/SP.AppContextSite(@target)/web/Lists/getbytitle('" + listName + "')? @target='" + hostweburl + "'",
method: "GET",
headers: {
"content-type": "application/json; odata=verbose", "Accept": "application/json;odata=verbose"
},
success: onExist,
error: onNotExist
});
}
No comments:
Post a Comment