Quantcast
Channel: Developing Apps for SharePoint 2013 forum
Viewing all articles
Browse latest Browse all 8089

Accessing External Lists of top level site in App part using java script Client object model in O365

$
0
0

Hi All,

I am getting below issue while accessing External Lists of top level site (Host web) in App part using JavaScript Client object model.  

System.UnauthorizedAccessException 

Access denied. You do not have permission to perform this action or access this resource.

Observations

From App Part

1. Same code if I execute from App part accessing any other default lists it is working fine.

From Top Level Site page

2.Same code if I place it Content editor Web part of Top level site page (after removing AppContextSite related code) and try accessing External list it is working fine. 

3.Same code if I place it Content editor Web part of subsite site page (after removing AppContextSite related code) and try accessing External list it is working fine. 

Not able to understand the exact reason why is it failing when we try to access external list from AppPart

any thoughts on this would be really helpful.

Code Sample which I tried

function retrieveBCSListItems() {

    var hostWebUrl = decodeURIComponent(manageQueryStringParameter('SPHostUrl'));
    var AppWebUrl = decodeURIComponent(manageQueryStringParameter('SPAppWebUrl'));

    // var clientContext = new SP.ClientContext(hostWebUrl);
    var clientContext = SP.ClientContext.get_current();

    var listSiteCtx = new SP.AppContextSite(clientContext, hostWebUrl);
    var listSiteWeb = listSiteCtx.get_web();

    var oList = listSiteWeb.get_lists().getByTitle("Personaldetails");

    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml("<View>" +"<Query>" +"<Where><Eq>" +"<FieldRef Name='FirstName' />" +"<Value Type='Text'>Raghu</Value>" +"</Eq></Where>" +"</Query>" +"</View>");
    collListItem = oList.getItems(camlQuery);
    clientContext.load(collListItem);
    clientContext.executeQueryAsync(onQuerySucceeded, onQueryFailed);
}



ragava_28


Viewing all articles
Browse latest Browse all 8089

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>