0

I have a SharePoint App that I am creating for SharePoint Online. I am leveraging the out of the box SharePoint Snippet in Visual Studio using the listview snippet.

List View Snippet:

<WebPartPages:WebPartZone runat="server" FrameType="TitleBarOnly" ID="full" Title="loc:full">
    <WebPartPages:XsltListViewWebPart runat="server"
        ListUrl="https://mySite.sharepoint.com/sites/spdev/demo/Lists/TestList1/AllItems.aspx"
        IsIncluded="True"
        JsLink="clientTemplate.js"
        NoDefaultStyle="TRUE"
        PageType="PAGE_NORMALVIEW"
        Default="False"
        ViewContentTypeId="0x">
    </WebPartPages:XsltListViewWebPart>
</WebPartPages:WebPartZone>

enter image description here

The Snippet works great when I'm using a list that I create in Visual Studio but not when I'm trying to read a list that exists on the parent site (within the same site collection). The error I'm getting is:

Untitled

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

However, I have given Full Control to multiple things (in an attempt to get around this error). But I still receive the same message every time.

enter image description here

Is there something that I'm doing wrong?

UPDATE1

I tried modifying the XML to use the ListId instead and it instead errored out and directed me to the web part maintenance page.

<WebPartPages:WebPartZone runat="server" FrameType="TitleBarOnly" ID="full" Title="loc:full">
    <WebPartPages:XsltListViewWebPart runat="server"

        ListId="26F0CCFF-3080-49C4-A731-7E4108D5B98A"

        IsIncluded="True"
        JsLink="clientTemplate.js"
        NoDefaultStyle="TRUE"
        PageType="PAGE_NORMALVIEW"
        Default="False"
        ViewContentTypeId="0x">
    </WebPartPages:XsltListViewWebPart>
</WebPartPages:WebPartZone>

List Resides At: https://mySite.sharepoint.com/sites/spdev/demo/Lists/TestList1/AllItems.aspx

Web Pat Is At: https://mySite.sharepoint.com/sites/spdev/demo/mySiteListView/Pages/Default.aspx

What am I doing wrong? Is it possible to access a list from a subsite within the same site collection?

Thanks in advance for any helpful input!

3
  • can you show the error from ULS log so we know whwere the access denied is being sent from on what resource? thanks
    – Ali Jafer
    Sep 17, 2014 at 8:35
  • I would love to provide that but this is SharePoint Online and from what I've read, I don't have access to those logs. Apparently the only way to obtain those logs is to go through a long process with Microsoft and in some cases, they will only provide you with a fraction of what you need. I hope I'm wrong here, so please correct me if that's the case!
    – mwilson
    Sep 18, 2014 at 0:55
  • you can, kindof ;), use powershell Get-SPOAppErrors -ProductId ba51729b-e017-409d-681a-66f1dd18f0f4 technet.microsoft.com/en-us/library/fp161379.aspx , i would recreate the error and then run the powershell code using the new error guid it produces
    – Ali Jafer
    Sep 18, 2014 at 7:01

5 Answers 5

1

first off, its a sharepoint app part. Secondly i understand you gave control but where? have you given control though the app part?

first edit the app part by going to properties ->

enter image description here

now select the permission on the left side to show you the permissions for the application part. You should see several dropdowns, I presume the app part is only trying to read content from the web object and not site collection level so click on content to expand the options for content security -> now under web slide to read only as i presume thats all you want todo? otherwise set accordingly -> close it down by clicking on the x button (top right) and redeploy app part.

when you run the app part you should now get a popup stating do you trust the application? just click yes to run and you shouldnt get access denied anymore!

If an app is granted permission to one of the scopes, the permission applies to all children of the scope. For example, if an app is granted permission to a website, the app is also granted permission to each list that is contained in the website, and all list items that are in each list.

Because permission requests are made without information about the topology of the site collection where the app is installed, the scope is expressed as a type instead of as the URL of a specific instance. These scope types are expressed as URIs. Permissions to resources that are stored in the SharePoint content database are organized under the following URI:

http://sharepoint/content.

and also:

Unlike SharePoint user roles, these rights levels are not customizable. This is to ensure that when an app is granted a permission request, the app is guaranteed a predictable set of capabilities, and it does not have to account for the possibility of being granted less permission than it expects.

A user cannot grant an app permissions that the user himself or herself does not have. If a user attempts to install an app that requests more permissions than the user has, an error message displays to the user informing them that they don't have sufficient permissions to grant the app its request.

Permissions that are not known to SharePoint are ignored. This means that, if an app requests a permission that SharePoint does not recognize, the app can still be installed, but the user is not prompted to grant the permission, and the permission is not granted to the app.

http://msdn.microsoft.com/en-us/library/office/fp142383(v=office.15).aspx

1
  • Hi Ali, thanks for the detailed information. However, I have already done the permissions within the AppManifest and do receive the 'do you want to trust this app' when I deploy it. I still receive getting access denied after giving pretty much any relative option Full Control. This is shown in the second screen shot. What I'm confused about it the screen shot you provided is different and I do not see that anywhere in Visual Studio other than the appmanifest file. I have also watched the video provided and still no different behavior than Access Denied.
    – mwilson
    Sep 19, 2014 at 1:05
0

You can try to setup WebId property of XsltListViewWebPart

3
  • Can you point me to a thread or documentation on how to utilize that property?
    – mwilson
    Sep 12, 2014 at 20:29
  • It pretty the same as other XsltListViewWebPart properties: <WebPartPages:XsltListViewWebPart runat="server"... WebId="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"></WebPartPages:XsltListViewWebPart> where XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX - GUID of your SPWeb containing source list Sep 13, 2014 at 10:46
  • Oh, I understand. Thanks! However, I see this complicating things further as SharePoint Online doesn't seem to have an easy way of getting the WebId. Since this app will (hopefully) end up in SharePoint Store, I will never know the web id.
    – mwilson
    Sep 16, 2014 at 0:10
0

you can get the web id easily.. use below code to get it.

            <script src="/_layouts/15/SP.Runtime.js"></script>
        <script src="/_layouts/15/SP.js"></script>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" ></script>
        <script type="text/javascript">

                    $(document).ready(function () {
                          GetWebID();
                    });
                    function GetWebID()
                {
                    var context = new SP.ClientContext.get_current();
                    this.Web = context.get_web();
                    context.load(this.Web);
                    context.executeQueryAsync(Function.createDelegate(this, this.onSuccess),
                        Function.createDelegate(this, this.onFail));
                }

                function onSuccess(sender, args)
                {
                  alert(this.Web.get_id());
                }

                function onFail(sender, args) {
                    alert('Failed:' + args.get_message());
                }
                </script>

Also check that you have given proper access to your style library. Hope this will help you :)

4
  • Is currentUser supposed to be in there? Doesn't look like it's doing anything.
    – mwilson
    Sep 16, 2014 at 23:12
  • Would WebId replace ListUrl? I always receive an error when i reference the webid in the xml
    – mwilson
    Sep 16, 2014 at 23:18
  • Using the WebId didn't work. I still receive the same error message.
    – mwilson
    Sep 16, 2014 at 23:32
  • currentuser is not required :(
    – Manu Singh
    Sep 17, 2014 at 6:14
0

Give permission in App at list level. And check that list permission is inheriting from its parent, it should not break. If it break then you must have permission in that list.

Check these things, otherwise things should gonna work perfectly!

0

It is not possible to access a list from a parent site (even though it's within the same Site Collection). This can be done using other methods such as using the REST API but cannot be done by using the out of the box visual studio splistview snippet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.