API for interacting with SharePoint from .NET, Silverlight, and JavaScript.

learn more… | top users | synonyms (1)

37
votes
6answers
31k views

How do you get the current list item in JavaScript?

There's all kinds of ECMAScript class library examples around but all of the ones I find show how to retrieve all list items (through SP.ClientContent) but how do you get the current list item? I'm ...
33
votes
10answers
17k views

How do I know if the page is in Edit Mode from JavaScript?

Is there a way to find out if a page is in Edit Mode from JavaScript? I know in on the server-side can be found using SPContext.Current.FormContext.FormMode but I can't find any means of doing it ...
13
votes
5answers
4k views

WebServices or Client object model?

I am writing a Silverlight control which will display the data from SharePoint list for use in SharePoint 2010 site. I am considering wheather to use Client Object Model or SharePoint web services ...
12
votes
3answers
3k views

Client Object Model equivalent of SPUtility.SendEmail in SharePoint 2010

I am trying to send an email after an action occurs in Silverlight WebPart I am designing. Is there a built-in class in the Client Object Model that can handle this, or will I have to build a ...
12
votes
2answers
2k views

Cannot add custom web part to page using the JS OM

I'm trying to add a custom web part (that is one I have written myself) using the new Javascipt OM available with SharePoint 2010. My solution is also running within the Sandbox. I have it working ...
10
votes
3answers
4k views

Grab a specific property bag using ECMA script

I am trying to grab a key/value pair from a specific property bag but can't find any documentation or example code on how to grab a property bag. Currently I can only seem to grab allProperties. Here ...
10
votes
1answer
3k views

Client Object Model Equivalent of SPSiteDataQuery?

I'm looking for an equivalent to the SPSiteDataQuery functionality in the Client Object Model (COM). The CamlQuery can be used with an instance of List to execute SPQuery level of aggregation, but is ...
9
votes
2answers
8k views

Pass parameters in ExecuteOrDelayuntilScriptLoaded in Javascript client Object model

I have written a javascript client-object model code and I am calling it through the below line code from content editor webpart: ExecuteOrDelayUntilScriptLoaded(getWebSiteData(sys), "sp.js");// ...
9
votes
3answers
8k views

How to traverse SharePoint Library in Client Object Model?

I have SharePoint Library and i want to traverse all folder and sub folder of it using client object model. Can anybody have solution ?
9
votes
3answers
13k views

How to get all items in a View using Client Object Model (JavaScript)

To get all the items in a List you use // Setup context & load web context = new SP.ClientContext.get_current(); web = context.get_web(); context.load(web); // Load task list this.List = ...
9
votes
2answers
725 views

Opening and closing AssetPortalBrowser.aspx in SharePoint modal popup

I am trying to open the "OOB" AssetPortalBrowser.aspx from a page within a SharePoint native modal popup. My aim is to get the selected filename back to the script. So far I was able to open the ...
9
votes
1answer
204 views

Passing args to QuickLinksDialog with JS

I have a small button on a site which when i press should start a QuickLinksDialog and fill in some of the fields there. Everything goes good and well except the fields (like: title and url) still ...
8
votes
5answers
6k views

Creating Nested Folders via Client Object Model

I'm trying to create nested folders in my document library so it looks like this: http://site/PublicDocuments/Folder1/Folder2/Folder3/ The document library "Public Documents" exists but none of the ...
8
votes
3answers
3k views

How to add list web part to the SharePoint page using Managed Client Object Model?

I am trying to add new web part to the SharePoint page using Managed Client Object Model that will display a list. I can't seem to be able to figure out the code of the web part's XML that is ...
8
votes
3answers
17k views

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

We have a database with absolute (full) links to SharePoint files. If a user wants to download or get checkoutstatus information about the file, our program needs lookup that information in ...
8
votes
1answer
3k views

How to Impersonate Users Via Client Object Model?

I want to insert new SP List items -- blog comments, to be exact -- on behalf of other users. Ideally, I'd just pass a SharepointID for the user, but that doesn't seem to be possible. I think that ...
8
votes
3answers
12k views

How can I use the SharePoint Javascript Object Model from a plain HTML page?

I would like to use the SharePoint Javascript Object Model from a "plain" html page (ie, not an .aspx application page etc.) Is this even possible? If so, what scripts should I reference? I've added ...
8
votes
1answer
1k views

How to get WebPart on current page by name/ID with javascript?

I have a page with some webparts on it, I want to get specific one (by name or ID) using client javascript. I try this code var ctx=SP.ClientContext.get_current(); var web = ctx.get_web(); var site ...
7
votes
1answer
4k views

Get a value included from a lookup column using the JavaScript Client Object Model

Related: How to retrieve a ListItem using the Javascript Client Object Model? In my previous question I was able to successfully retrieve a basic value from a list item. My problem is that I am now ...
7
votes
4answers
2k views

How to access a Web application/Farm level property bag via jQuery/Javascript/ClientContext

It it possible to access the Web application/Farm level property bag using jQuery/Javscript/ClientContext? If not, then what are the possible alternatives to access Web Application Farm level property ...
7
votes
1answer
4k views

How to get a list of all Choice field options using Client Object Model

How would you get a list of all the possible choices from a choice field (e.g. Task list Priority or Status fields) using javascript client object model?
7
votes
1answer
794 views

Client Object Model SystemUpdate

I need to have the SystemUpdate functionality from the Client Object Model. Is there any way I can do it since the ListItem.SystemUpdate() does not exist? Another solution would be to disable the ...
7
votes
1answer
535 views

JavaScript Client Object Model functionality to get all the non hidden lists of current web and listing them

We have requirement to get all the non hidden lists of current web using JavaScript Client Object Model(JSOM). I have tried the below code but failed to get the desired result. function ...
7
votes
3answers
6k views

How to get the ID of the list item just inserted using ecmascript

I am stuck at a place where I have to update a list which has a Lookup column. For example I am using this code to update my normal list var clientContext = SP.ClientContext.get_current(); ...
7
votes
4answers
5k views

ExecuteOrDelayUntilScriptLoaded too slow in Firefox and Chrome

I want to use CSOM but waiting around 2 or 3 seconds after page load before I can even do my first query is crazy! See below. Using jQuery dom ready shows a reasonable ready time, but SP.ClientContext ...
7
votes
1answer
2k views

Create a Document Library Item base on a ContentType with JavaScript Object Model (JSOM)

I'm trying to create a new item in my Entreprise Wiki Pages Document Library. It's associated with a News Content type. I was able to retrieve the SP.List object (myList), the SP.ContentType object ...
6
votes
4answers
17k views

Get Site Collection full URL using javascript

I want to get the URL for my site collection. One way I thought I could do it was using the window.location in javascript and getting it that way. I know that you can use ECMA script and the client ...
6
votes
4answers
10k views

Javascript to display sharepoint list items on page load

With Client Object Model API and a bit of javascript, I want to retrieve the items of a sharepoint list and display them into the web page, when the web page loads. I've successfully implemented ...
6
votes
2answers
13k views

ExecuteOrDelayUntilScriptLoaded not executing after page publish

In SharePoint 2013 I have a page that is using the Script Editor web part. In the script editor web part I have the following: ExecuteOrDelayUntilScriptLoaded(startIt, "sp.js"); function startIt() { ...
6
votes
6answers
10k views

How do I determine a user's SharePoint group membership using the client object model?

I want to redirect users from a landing page to another page in SharePoint 2010, based on their group membership. I need to do this using JavaScript (ECMAScript) and not server side code.
6
votes
5answers
1k views

When I execute a CAML query, how do I know what ListItem details I can include?

I was querying a SharePoint library, trying to retrieve some file attributes. Apparently some things like FileType and Date are not supported, even though those fields are listed as a built in field. ...
6
votes
2answers
1k views

how to set list alert using javascript in sharepoint 2010?

I need to set a list alert for current (logged in) user using javascript. var currentcontext = new SP.ClientContext.get_current(); var currentweb = currentcontext.get_web(); ...
6
votes
1answer
3k views

CSOM Get ListItem of Folder

In an application I'm working on, I'm interacting with SharePoint (2010) via the .NET Client-Side Object Model, and am trying to account for a large number of possible configurations of document ...
6
votes
3answers
9k views

How to access list in SharePoint Hosted App?

I want to create an Sharepoint hosted app but how to access list in these App ??
6
votes
4answers
7k views

SharePoint 2010 Javascript Client Object Model cross site collections?

I've read some unofficial things online that using the Javascript client object model to retrieve content from other site collections is not allowed due to prevent the equivalent of "cross site ...
6
votes
1answer
2k views

Fetch list of sites in site collection into jQuery

Is there a way to get the list of sites in the current site collection into jQuery as an array or other data structure? Thanks.
6
votes
1answer
1k views

Working With Content Approval / Moderation In CSOM

The SharePoint Object Model provides a property of an SPListItem called SPListItem.ModerationInformation.Status to allow you to determine the current content approval / moderation status if a document ...
6
votes
1answer
1k views

JavaScript Client object model, rename folder

I am trying to rename a folder inside a Document library. Right now I get my item and everything is good but when I try to rename it using set_item('title', 'NewFolderName') it crashes and unwinds the ...
6
votes
2answers
3k views

moveTo and moving documents from one library to another

I have followed and successfully implemented the excellent article: SharePoint 2010 ECMAscript – Copy\Move files to another document library – Part 2 located at: ...
6
votes
1answer
2k views

Context Menus - Send To not working in IE9

I have a document center with a custom master page. The page is designed with IE9/HTML5/CSS3 in mind. In my other question, I worked out how to fix the IM Presence icons by fixing some core ...
6
votes
2answers
7k views

Get list by Internal Name using ECMAScript / JavaScript Object Model

How can I load items from a list using its InternalName? As far as I know I can get it using either Id or Title like the following: var clientContext = new SP.ClientContext('/News/'); var web = ...
6
votes
2answers
2k views

How to retrieve distinct values with JavaScript Client Object Model

How can you get distinct values from a SharePoint List column using JavaScript without a huge performance hit? A simple example would be appreciated :)
6
votes
2answers
3k views

How to create SharePoint list with custom template using Managed Client Object Model?

Creating lists in SharePoint using Managed Client Object Model is rather easy task. Here's how to create a list with SharePoint's custom list template: ListCreationInformation lci; List list; lci = ...
6
votes
1answer
3k views

How to Upload File to Document Library using JavaScript Client Object Model?

I want to Upload File to a Document Library using JavaScript in SharePoint 2010. I found that you can copy file from One Document Library to Another but you can't upload File using JavaScript on this ...
5
votes
4answers
1k views

js library for REST and JSOM SharePoint basic tasks

I am just sick of writing again and again the same piece of code to use jsom Async requests, especially when it's for a SP-hosted app which envokes spexecutor. I am sure each developer has his own ...
5
votes
3answers
5k views

How to Use ECMA CSOM to Set a Field of Type SPFieldUserValue

I have a JavaScript array containing the string representation of some usernames (domain\username format). Using the JavaScript CSOM, what is the best way to create a new item and add those usernames ...
5
votes
2answers
5k views

Check if user is in a specified group

I would like to check with JavaScript if the current logged user is in a specified and specific group (for example called "Admins Group"). How can I do? Thanks
5
votes
4answers
7k views

Get current web url in a SPRibbon Custom Action Command

I've a SPRibbon custom action with the purpose of open an custom app page in a modal dialog, but I'm getting troubles for getting the current web URL, as well, set a reference for a .js with the right ...
5
votes
3answers
10k views

Cannot get field value of list item through JavaScript

I try to get the value of a list item (that is currently selected). I know that I must load it into the context but even with loading the field explicitly I get the following message. Microsoft ...
5
votes
1answer
487 views

structure of sharepoint javascript functions

I am trying to understand more the structure of javascript functions in SharePoint. Why does every function begin with som value than colon and semicolon like ULSrE8:; in spgridview.debug.js: ...