csom,sharepoint-online , Determine which list a provider hosted application has access to

Determine which list a provider hosted application has access to


Tag: csom,sharepoint-online

I have created a simple Provider Hosted App ( straight out of the Visual Studio 2013 box )

The App has been granted "Read List Permissions" in the app manifest.

When the app is deployed SharePoint Online asks the User to select the list that the app can access. This should give it permission to read one specific list on the Host Web.

I cannot figure out how the MVC Provider Hosted Web part of the application actually determines which SharePoint list the end user has granted it permission to read.

Presumable it gets some sort of token to tell it which list it can read? Or is their a CSOM/JSOM call that will reveal which list it can access?


To determine which list the user has granted permission to read you could consider the following approach:


1)For current user

using (var ctx = new ClientContext(webUri))
        var web = ctx.Web;

             lists => lists.Include(list => list.Title,
                                    list => list.EffectiveBasePermissions));

        var currentUserLists = web.Lists.Where(l => l.EffectiveBasePermissions.Has(PermissionKind.OpenItems));

2)For any user

using (var ctx = new ClientContext(webUri))
     var web = ctx.Web;

     //load lists
     //load lists permissions for a specified user
     var listsPermissionsResults = web.Lists.ToDictionary(list => list, list => list.GetUserEffectivePermissions(loginName));

     //filter lists where user has been granted permissions to open list 
     var userLists = new List<List>();
     foreach (var result in listsPermissionsResults)
           var list = result.Key;
           var listPermissions = result.Value.Value;
           if (listPermissions.Has(PermissionKind.OpenItems))


jQuery .css() not getting background position w/o !important in css

I am hoping someone could help me understand why the jQuery .css() (v1.11) method is returning 0% 0% for elements that have a non-overridden background position defined (in the inspector while running and in the style sheet). What I found a bit puzzling is why when I force an !important...

SharePoint Online (Office 365) login form in a Office task pane app

The end goal of what I am trying to achieve is to open a page from a SharePoint Online instance - any page, it doesn't matter - in a Office Task Pane app. The issue is that the login page (https://login.microsoftonline.com) is shown fine, but when you click 'login' it...

Retrieve all instances of recurring event via CSOM

I need to get all the instances of a recurring calendar event in Sharepoint 2013 online via CSOM. I read that it can't be done, that I need to do it via REST API directly. My question: 1) Is it possible to get the items from a View instead of...

Call Javascript After Saving Calendar Item

I am having a script as below:- function getColorValue(aId,atitle) { try{ var clientContext = new SP.ClientContext(); var oWebsite = clientContext.get_web(); var oList = oWebsite.get_lists().getByTitle('Item type'); var oListItem = oList.getItemById(parseInt(aId)); clientContext.load(oListItem); clientContext.executeQueryAsync(function () { var listItem = oListItem; var colorname = listItem.get_item('Color_x0020_Name'); if (typeof colorname != 'undefined') { if (colorname !=...

Creating term fails in SP 2013

I am trying to create a term in a SP 2013 term set. I am able to read the terms from the term set with the given credentials. Settings: The ServiceAccountLogonName user is one of the Term Store Admins Code: var siteUrl = ConfigHelper.GetValue("SharepointSiteUrl"); var clientContext = new ClientContext(siteUrl); clientContext.Credentials...

SharePoint Online integrated with CRM Online says, “We're sorry, we can't sync because you've run out of space.”

I was trying to sync my document on SharePoint Online where I got an error saying, "we're sorry, we can't sync because you've run out of space." I believe this is independent of the CRM storage space we get (which is still under 8% filled for my CRM organization) How...

Checking if current user can view list in SharePoint CSOM

How do I determine if the current user can view list items or read a list in SharePoint Online / Office365? I have some working code that returns the lists // Retrieve all lists from the server. context.Load(web.Lists, lists => lists.Include(list => list.Title, list => list.Id, list => list.Hidden, list...

Thumbnails in Sharepoint online

I need to show thumbnails of Sharepoint Online images on my website, to avoid downloading all images beforehand. Is it possible to make Sharepoint Online (Office365) automatically create thumbnails (user defined size) of images that you upload? Or is it possible to make SO scale the image before download, by...

SHAREPOINT 2013: How can I read Site column contents and modify them via javascript csom?

I'm relative new to Sharepoint 2013, I'm trying to access and display on a page the contents inside a specific "Site Column", I've have been reading a lot about this, but I still can't accomplish my task. So far I get to this: 'use strict'; var hostweburl; var appweburl; $(function...

SHAREPOINT 2013: How can I update a Site Column with the content of an array with javascript CSOM?

I'm relative new to Sharepoint 2013, I'm trying to update the content of a Site column with the content of an array, I can retrieve and visualize the content of my site column, the user is able to change and save the necessary part and the changes are saved into...

How to prevent fill in values when saving over CSOM to a choice field

I am writing some ETL code to move data between an external system and SharePoint Online. I am using the nuget package Microsoft.SharePointOnline.CSOM to communicate with SP in C#. I am using the following code to update my field values. spListItem[fieldName] = "Test Value"; spListItem.Update(); spClientContext.ExecuteQuery(); I noticed with Choice...

Add Button in SharePoint List Ribbon Button Using JSOM

I have to add a button in Sharepoint List Ribbon button & in ECB Menu. here is the code to add ECB menu in Sharepoint List using JSOM. function AddCustomActions() { var listTitle = 'mylist Title'; var clientContext = new SP.ClientContext(); var oWebsite = clientContext.get_web(); var oList = oWebsite.get_lists().getByTitle(listTitle); var...

How to enableMajor?

How could I enable Major versioning on "Pages" list? My code is not working and I don't get any errors. Any suggestions?.... _spBodyOnLoadFunctionNames.push(onPageLoad()); function onPageLoad() { ExecuteOrDelayUntilScriptLoaded(enableMajor, 'SP.js') } function enableMajor() { var ctx = new SP.ClientContext.get_current(); var list = ctx.get_web().get_lists().getByTitle('Pages'); ctx.load(list); ctx.executeQueryAsync( function () { list.enableMajor = true; },...

How to redirect a URL in SharePoint Online?

I have a site setup in SharePoint online at: aaa.sharepoint.com/fr The trouble is that this is an internal acronym and new staff always go to the long version of this URL. Is there a way I can redirect aaa.sharepoint.com/fundraising to aaa.sharepoint.com/fr without having to create another SharePoint site and a...

C# CSOM - Check if File Exists in Document Library

I'm coding in C# using CSOM, my app uploads a template asp.net page to the "/Pages/" library, I need it to check if a file exists in that location with the same name prior to file upload (then maybe it can return a bool value). I did have a quick...