Javascript is a dynamic computer programming language, most commonly used as part of web browsers, whose implementations allow client-side scripts to interact with the user, control the browser, communicate asynchronously, and alter the document content that is displayed.

learn more… | top users | synonyms (2)

5
votes
8answers
19k views

Getting a count of list items in a list via ECMAScript

I have a SharePoint 2010 web site with a master page that has a counter on it. I'm trying to update that counter using the ECMAScript. The code I have falls nicely into the success method - but I ...
31
votes
9answers
14k 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 ...
8
votes
3answers
8k views

SP.SOD how to use correctly?

SP.SOD is a nice feature of SharePoint, but how should I use it? For example, I use these lines of code ExecuteOrDelayUntilScriptLoaded(function () { //code }, "custom.js"); If I understand ...
37
votes
6answers
28k 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 ...
10
votes
3answers
3k 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 ...
6
votes
4answers
1k views

How can I disable the Document Library drag and drop function?

Before I start - I'm new to this SharePoint development lark and am slowly familiarising myself with it. We're using SharePoint online and I have amended the SharePoint out-of-the-box document ...
5
votes
1answer
464 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: ...
4
votes
5answers
16k views

How to get current user with javascript?

I have a list . I want select items of list with a special quary.(get items that created with current user). Then get count of items. I use this code for get current user : function Initialize() { ...
5
votes
7answers
5k views

What is the proper way to add jQuery to a MasterPage?

Currently I am using this method in the header: <script src="/_layouts/MNCAssets/scripts/jquery-1.5.1.min.js"></script> But for some reason, my webparts that use jQuery don't appear to ...
4
votes
3answers
4k 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 ...
0
votes
1answer
37 views

SessionStorage caching when getting items from a list

SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady); var listTitle = []; var listUrl = []; var listIsActive = []; var listOrder = []; function sharePointReady(){ var siteUrl = mysite; ...
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 ...
9
votes
2answers
8k views

Programmatically add JS/CSS to pages

I've created a Visual Studio SharePoint 2010 solution with an ASCX that adds some JavaScript files and CSS to the head of each page; this is based on this article. When I deploy the solution, it adds ...
3
votes
2answers
23k views

SP.ClientContext.get_current() returning undefined objects

I am trying to get some information about the current context through the sharepoint javascript object model and am getting annoying errors. $(document).ready(function () { ...
5
votes
3answers
3k views

Can't upload a non-text file to SharePoint App via REST API

I am using the following REST code to add a file as an attachment to a SharePoint 2013 list item. <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server"> <SharePoint:ScriptLink ...
7
votes
1answer
3k 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?
6
votes
3answers
9k 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 ...
5
votes
3answers
9k views

How to use JavaScript and CSS in a web part?

I am using SharePoint Server 2007 Enterprise with Windows Server 2008 Enterprise. I am using publishing portal template. I am developing using VSTS 2008 + C# + .Net 3.5 + ASP.Net. And I want to ...
2
votes
1answer
6k views

How can I pass a Parameter via Query String to populate a lookup field on a New Item Form/DVWP?

I have two lists: List A: Products List B: Requirements I'd like to have a nice Create Requirement page launched from the Product Listing page. I have a DVWP/Multi-Item View displaying all ...
7
votes
4answers
1k 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 ...
4
votes
1answer
1k views

SharePoint RTE: How to attach to mousedown events (like bold, italic does)

When clicking on bold text in the RTE (rich text editor), magically the ribbon button for bold: get's activated. The same happens for the other format option buttons you can see on the screenshot. I ...
2
votes
3answers
2k views

Add (replace) hyperlink to pictures in a Picture Library Slideshow Web Part

On our team site we have added a web part that is a "Picture Library Slideshow" web part. Currently clicking on the images that scroll in the slideshow directs the browser to just the image's URL. I ...
2
votes
3answers
2k views

How to get value of List Filter web part in Javascript?

I use the SharePoint List Filter web part on a page to control several Data View Web Parts. How do I read the current value of the List Filter in Javascript?
5
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.
4
votes
2answers
2k views

Sharepoint 2010 ModalDialog title

I am creating a popup window in sharepoint using this code in javascript. function openDialog(title, url, width, height, CallResult) { var options = { url: getUrl(url), title: title, ...
3
votes
2answers
2k views

Using Sharepoint client API to upload file as attachment in javascript

is there a way to upload file as attachment while using JavaScript client object model in sharepoint 2013? Or using web service in the middle is required? I cannot use FileAPI from HTML5. Thank you ...
2
votes
4answers
2k views

How can I Make a Dropdown box in a Form Field Conditionally Read-only/locked?

I have a drop down box form field (with values level1,level2) in SharePoint list. How can I lock the drop down box selection in the edit form.aspx whenever the condition is level2?
1
vote
1answer
1k views

Reference a javascript script in a ribbon custom action xml

Reference a .js file on a spribbon custom action elements.xml on my javascriptmethods.js file: function test(){ alert('test message.');} on my custom action elements.xml: <CustomAction ...
4
votes
2answers
9k 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() { ...
4
votes
1answer
7k views

How to get all fields of a list using JS Client Object Model

Is it possible to retrieve all fields of a list (or default view) through the JavaScript Client Object Model and filter the fields on type (e.g. I only want the Choice fields). var clientContext ...
3
votes
2answers
12k views

Get current user in Client Object Model with javascript?

var ctx = new SP.ClientContext.get_current(); var web = ctx.get_web(); ctx.load(web); var user = web.get_currentUser(); alert(user); I used above code to get the current user using JavaScript, but I ...
3
votes
3answers
3k views

Javascript to get GUID from SharePoint

I am newbie to SharePoint and I am uploading a file to the server using javascript. Now the task is to get the GUID of that file and display it ({alert(guid); is fine). I don't even know where to ...
2
votes
1answer
12k views

Calling the SP.UI.ModalDialog.showModalDialog method

My SharePoint solution has a userControl that Register a js block string getJS(string title, string htmlContent) { return (string.Format(@" ExecuteOrDelayUntilScriptLoaded(function ...
1
vote
2answers
110 views

Error while accessing the User profile properties via JS code

Code gives error 2 times out of 10 attempts to refresh the page. We get error as: Request failed, unexpected responce from server. The status code of response is '0'. The status text of ...
1
vote
1answer
1k views

Are the SP.js and SP.UserProfiles.js preloaded in SharePoint?

I am using the javascript object model on the master page to fetch user profile properties. Do I need to use the foll. script tags for the code to work or are they optional? ...
1
vote
2answers
2k views

PreSaveAction is not firing

Any idea why the PreSaveAction is not firing. I am trying to take the user to a thankyou page when they complete a survey. I added this js thru SP Designer to NewForm.aspx. <script ...
1
vote
1answer
7k views

How to retrieve a ListItem using the Javascript Client Object Model?

Right now I am using this method: function getWebProperties(id) { var ctx = new SP.ClientContext.get_current(); this.website = ctx.get_web(); this.listCollection = website.get_lists(); ...
1
vote
0answers
467 views

Get group membership of current users using ECMAScript [duplicate]

Possible Duplicate: How do I determine a user's SharePoint group membership using the client object model? How can I use the client object model to get a list of all (SP) groups the ...
0
votes
0answers
73 views

Unable to execute succeeded() & failed() functions after ModalDialogPopup's CloseDialog()?

I wrote javascript for changing checkbox(IsDeleted) value from No to Yes while clicking on delete button. Here ModalDialogPopup taken for confirmation , if it is 'No' the modalpopup will close the ...
0
votes
2answers
1k views

Get Icon URL and filename of document library file using JSOM in office 365 app

I have an app that includes a Document Library...using my normal code to display the list but keep getting a null on the field...i've tried rptDocsListItem1.get_item("xd_ProgID") and ...
0
votes
2answers
931 views

Defer SP.RequestExecutor.executeAsync

I'm working on a SharePoint app where I need to run SP.RequestExecutor.executeAsync() in order to grab some information from one of the Host Web's lists. Depending on what method is calling the oData ...
0
votes
1answer
473 views

AllItems View of Query String: can I group using value in query string?

Can I somehow how a query string to show a group of documents within a given library. Not one single item, but the AllItems like view. So within the library I have a grouping type of id value in a ...
0
votes
3answers
4k views

Get the user id via javascript

How can you get the current users id using javascript? Can you do this any JS file or does it need to be added at a certain point?
7
votes
3answers
4k views

How to avoid caching issue when using custom JavaScript and CSS deployed under _layouts?

On our farm, I'm deploying some JavaScript and CSS files under the _layouts folder. I'm then referencing them, where it's required using a <SharePoint:ScriptLink> or a ...
13
votes
1answer
2k views

Change Sharepoint language with a link?

Is there a way to get the language-switch control as static link in the pagelayout? I want my users to switch between German and English with a single click. Sorry guys, found a solution :D ...
9
votes
3answers
5k views

Get the current UI language with ECMAScript

Is it possible to get the display language from within ECMAScript? Similar to http://www.sharepointoverflow.com/questions/3129/get-the-current-ui-language-from-a-webpart, I'd like to get the user's ...
7
votes
3answers
10k 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 ...
5
votes
3answers
8k 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 ??
5
votes
2answers
1k 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 :)
1
vote
5answers
2k views

How do I Inherit the CSS Theme Color in my Sharepoint 2013 App?

I am building a Sharepoint 2013 App in Javascript / HTML / CSS and I want to implement / inherit the color / class / css used by the theme. How do I do this? I want to ensure consistency through ...