13 votes
Accepted

Get list item url javascript object model

There is a property on the list for the default dispform, newform and editform url. Example: var clientContext = SP.ClientContext.get_current(); var list = clientContext.get_web().get_lists()....
Anders Aune's user avatar
  • 6,258
13 votes
Accepted

Get Parent web of a subsite using JSOM in SharePoint 2013

Using your SP.Web object, you can get the parent information (SP.WebInformation). Using its ID, you can then, via the site collection, get the parent web object. var context = new SP.ClientContext....
JayHell's user avatar
  • 1,478
12 votes
Accepted

How to check if the file or folder exist in SharePoint document library using client object model?

The following extension method demonstrates how determine whether file exist or not: using Microsoft.SharePoint.Client; namespace SharePoint.Client.Extensions { public static class WebExtensions ...
Vadim Gremyachev's user avatar
9 votes
Accepted

Set request access email address through CSOM

In the newest release of the "SharePoint Online Management Shell" (v16.0.4630.1200) the included Microsoft.SharePoint.Client.dll adds the property RequestAccessEmail to the Web class. Download: https:...
Stefan Born's user avatar
8 votes

Invoke Asset Picker from JSOM

Yes you can. I've written a wrapper utility for working with the SharePoint AssetURLSelector (or Asset Picker) that wraps the whole thing up in a nice Promise based API. Here's the essence of what you ...
Thomas's user avatar
  • 980
8 votes
Accepted

Differing ways to make executeQueryAsync calls - Function.createDelegate (is old IE8 code)

https://msdn.microsoft.com/en-us/library/office/dn168907.aspx states: SP.ClientContext.executeQueryAsync( succeededCallback , failedCallback ) So in both your examples you are referencing a ...
Danny '365CSI' Engelman's user avatar
8 votes
Accepted

camlQuery rowlimit not working on a list

SP.CamlQuery does not have a property RowLimit , you have to set in the caml markup: camlQuery.set_viewXml("<View><Query> <OrderBy> <FieldRef Name='ID' Ascending='False' /> ...
Anders Aune's user avatar
  • 6,258
7 votes

How to get only the document libraries from a sharePoint site using SharePoint Client Object Model?

This is better as it only pulls back the document libraries rather than all the lists which you then have to check in a loop. var Libraries = clientContext.LoadQuery(clientContext.Web.Lists.Where(l =...
Colin Gardner's user avatar
7 votes

PowerShell and the client object model: "The collection has not been initialized"

I was able to get it working in PowerShell with the CSOM via the following code. It's basically the same as Robert Kaucher's (in PowerShell format) with a minor change towards the end. Add-Type -...
Pete's user avatar
  • 71
7 votes

List API get all items limited to 100 rows

The option of querying items with $top is not advisable for performance reasons and impact on the network traffic. The best option is recursion. Note: Normally you have a callback on success and you ...
Emiliano Poggi's user avatar
7 votes

Check if user is in a specified group

This code worked for me, its simple and does the job var url = _spPageContextInfo.webAbsoluteUrl +'/_api/web/currentuser/groups' $.getJSON(url, function (data) { $.each(data.value, ...
Ahmed Masud's user avatar
7 votes

CSOM: How to get user groups specific to a site and not all the user groups in the site collection?

Here is how to do it in JS var clientContext = SP.ClientContext.get_current(); var web = clientContext.get_web(); var webGroupsCollection = web.get_roleAssignments().get_groups(); //gets a web ...
Shekar Reddy's user avatar
  • 1,793
7 votes

Get sub folder from document library using SharePoint.Client.dll

Folders are items as well. Just get the item and load the folder property. using (var ctx = new ClientContext(Constants.SharePointUri)) { var list = ctx.Site.RootWeb.Lists.GetByTitle(Constants....
Wout's user avatar
  • 1,605
6 votes

SP2013 online : set_formDigestHandlingEnabled Error

I had the same error message in a html without SharePoint Server rendering. For me I mixed up the load sequence of the sp.runtime.js and sp.js. You have to load the sp.runtime.js before the sp.js <...
sschoof's user avatar
  • 213
6 votes
Accepted

(ClientSide) set/update JSlink to CSR files for (all) WebParts, Views, Fields

I wrote my own JSLink Manager (runs as a Browser Bookmarklet) To: add/delete JSlinks on WebParts/Views in order Immediate save/apply on any change Have to refactor it a bit to work it into the iCSR ...
Danny '365CSI' Engelman's user avatar
6 votes

Get Parent web of a subsite using JSOM in SharePoint 2013

An alternative to using the get_parentWeb is using the _spPageContextInfo object for urls and only needs one execute: if(_spPageContextInfo.siteServerRelativeUrl != _spPageContextInfo....
Anders Aune's user avatar
  • 6,258
6 votes
Accepted

what happens with items/lists when the creating user is deleted?

Nothing happens with the list or the item, but when a user clicks on the author name (usr1) she won't see the removed users profile page. Unless items have unique permissions only accessible by usr1, ...
Benny Skogberg's user avatar
  • 25.5k
5 votes

How to get the login name of the current user using JavaScript?

It shows [object object] in your alert message because you are trying to display an object instead of its properties. [Object object] is the default serialization of an object in JavaScript. You can ...
Prasad De Silva's user avatar
5 votes

Check if user is in a specified group

Function: function isCurrentUserMemberOfGroup(groupName) { var userIsInGroup = false; $.ajax({ async: false, headers: { "accept": "application/json; odata=verbose" }, ...
Sergey's user avatar
  • 51
5 votes
Accepted

GetUserEffectivePermissions returns wrong results

I had the same problem as yours. I was passing username in format "domain\username" but it was returning all permissions as false. Finally I realized that I was using Claims based authentication for ...
xs2mayank's user avatar
  • 336
5 votes

How to create a list template by using CSOM?

The method SaveAsTemplate is not exposed in CSOM API, there is a general suggestion opened: Expose List.SaveAsTemplate() for CSOM API Basically you can create lists using already existing custom ...
Xavi's user avatar
  • 168
5 votes

Can webparts be added using the client side object model?

Yes, you can add webparts using the client side object model. Summary: Use the LimitedWebPartManager defined for C# or JavaScript. Adding webparts is generally considered part of a provisioning ...
John-M's user avatar
  • 5,920
5 votes

How to check if the file or folder exist in SharePoint document library using client object model?

I've seen many references to file.Exists not working in CSOM but the problem is typically caused by trying to do context.Load(file). If the file doesn't exist you can't load the file so the test ...
Martin D's user avatar
  • 141
5 votes
Accepted

executeQueryAsync don't behave as synchronously

As stated in the comments, you would need to structure your code in a way to get the result of the asynchronous operation, your code should be something like this: SP.SOD.executeFunc('sp.js', 'SP....
Mohamed Derhalli's user avatar
5 votes
Accepted

How does my app log into hosted Sharepoint (Sharepoint Online/Office365)?

When connecting to SharePoint Online, you should use SharePointOnlineCredentials instead of FormsAuthenticationLoginInfo. using (var context = new ClientContext("https://contoso.sharepoint.com")) { ...
dstarkowski's user avatar
  • 1,932
5 votes

Get Parent web of a subsite using JSOM in SharePoint 2013

Using REST API, it is very much easier to get parent web information. Just make a GET request to the following URL. _api/Web/ParentWeb In response, you will get all information about parent as like ...
Atish Kumar Dipongkor's user avatar
5 votes

Cannot Query Document Library with > 5K folders

In SharePoint Online, your only choice is to use REST. CSOM will not work. You call the REST endpoint and it will return a batch of 100 or 200 items, and if more exist, will return a paged link to ...
Eric Alexander's user avatar
5 votes
Accepted

CSOM C# Copy Library from one Site Collection to another with all folders / subfolders intact

Install the SharePoint 2019 CSOM library using the NuGet below. Install-Package Microsoft.SharePoint2019.CSOM -Version 16.0.10337.12109 Then use the methods of MoveCopyUtil class to copy/move ...
LZ_MSFT's user avatar
  • 6,209
4 votes

How to get a file using SharePoint Client Object Model with only an absolute url at hand?

Try something like this Uri filename = new Uri(@"file full url"); var f = this.Web.GetFileByServerRelativeUrl(filename.AbsolutePath); var stream = f.OpenBinaryStream(); this.Context.Load(f); this....
yunui's user avatar
  • 81
4 votes

CSOM OpenBinaryDirect generates 401 error on office 365

I had the same issue and solved this the following way: You do not need to use "OpenBinaryDirect()" but simply OpenBinary(), which does not require an url and does not return a stream directly, but a ...
Ole Albers's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible