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)

6
votes
3answers
8k views

REST API filter by start and end dates using 'today'

I'm new to filtering dates with REST in SP but am trying to do something like below but am not sure how to get today's date in as a variable into the request. I don't think I'm too far off so any help ...
6
votes
1answer
3k views

SP JSOM: is there any way to get the group by name instead of getById(10)

is there a way I can use the below with something like getByName(thisGroup), instead of getById(10) in SP 2010 jsom: function setSomeUsers(dataObj, projGroup) { var clientContext = new ...
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

no sorting with JavaScript Client Object Model?

I have the following JSOM code: var query = "<View><Query><Where><Eq><FieldRef Name='Category'/><Value ...
6
votes
2answers
11k views

How to return a value using context.executeQueryAsync?

How can I get this function to return the value? In all the examples I have seen, folks use an alert in the delegate functions, but I need to return the value instead. When I call the function, it ...
6
votes
1answer
2k 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
4k 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
2answers
9k 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
1answer
1k views

Get and remove all currently displayed notifications from SP.UI.Notify

I am sending a variety of notifications via SP.UI.Notify.addNotification("blah", true); setting the "sticky bit" to true so that the notification stays visible. When I display a second ...
6
votes
0answers
69 views

How to create ContentType with FieldLinks using REST on O365

I'm trying to create a ContentType with FieldLinks using REST only (no SP.ClientContext) on SharePoint Online, but I'm not able to make it work. Creating ContentType by POSTing to ...
6
votes
1answer
182 views

How to access a custom field of a list using REST

I'm trying to get information from a list in a custom SPField called "My Field" with the internal name "MyField" using this JavaScript code: $.ajax({ url: ...
5
votes
5answers
821 views

How can I include jQuery and JavaScript code without straying from the site template?

I've added my JavaScript code by including the script links in the PlaceHolderAdditionalPageHead <asp:Content> tag. Including this has caused a yellow warning stating The current page has ...
5
votes
6answers
8k views

Enforce Drag and Drop documents to apply metadata

We have implemented an issue management system in SharePoint 2013 which provisions a page for every issue added to a specific list. One of the Web Parts the automatically provisioned page contains ...
5
votes
3answers
32k 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 ...
5
votes
3answers
38k 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
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
9answers
32k 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 ...
5
votes
6answers
3k views

Get a SharePoint ListItem ID from a List where the 'Title' field is a specific value in JavaScript

I am trying to extract the ListItem ID of a List which I am currently NOT in based on a field value in that List. I cant find anything that explains how to do this. So, to explain. I have a Custom ...
5
votes
5answers
12k views

Add Javascript to every page in Sharepoint 2013

I looked but from what I see most questions that have anything to do with this refer to an old version of Sharepoint where something is always different from what I see in SP2013. I basically just ...
5
votes
2answers
770 views

SP 2010 JavaScript events

I want to hook into certain events on a SharePoint 2010 site, specifically the modal dialog open and close events. Does SharePoint 2010 trigger any events for these kinds of actions? If so, how do I ...
5
votes
3answers
12k 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
2answers
248 views

Get UserData - JavaScript

As seen in the following picture, when I add a User-Filter to a page it allows me to choose the parameter to pass. In my case I used the Büro. How can I retrive this data from client using ...
5
votes
1answer
521 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: ...
5
votes
4answers
6k views

Query SP2013 Managed metadata term store

I was wondering if it is possible to query the Term Store via the REST API or Javascript Client Object Model in SP2013. I can't quite seem to work out the naming scheme for the REST API to discover ...
5
votes
4answers
4k views

How to run javascript code only when list item gets deleted?

ANSWERED! See bottom of original question for the working answer. I'm trying to find out how I can run a piece of JavaScript code the moment a list item gets deleted. So it should be some sort of ...
5
votes
1answer
14k views

ExecuteOrDelayUntilScriptLoaded with sp.js when in debug mode Object Expected

I currently have a JavaScript file that gets loaded in my SharePoint pages. jQuery(document).ready(function() { ExecuteOrDelayUntilScriptLoaded(myfunction(), "sp.js"); }); myfunction = function(){ ...
5
votes
2answers
7k views

CSOM get list items, return simple data structure

If we take this code example, we can see we need to call a lot of methods to get to our results (.getEnumerator(), .get_current(), .get_title(), .get_title()) var siteUrl = '/sites/MySiteCollection'; ...
5
votes
3answers
739 views

Updating a single list item based on relative URL

Is it possible, using SPServices, to update a specific list item when all I have is the file path? For example, I have a file located at /site/library/folder/file.txt and I want to update a single ...
5
votes
4answers
12k views

Closing a modal dialog using a custom form

I am using some JavaScript (Client OM) code to open a dialog. Here's a snippet: function OpenModalForm() { //snip var opt = { url: url, width: 800, height: 600, ...
5
votes
1answer
2k views

JavaScript error using date picker inside an update panel?

I placed the SharePoint date picker control inside an update panel and when I click on the calendar it gives me this error: Microsoft JScript runtime error: The value of the property ...
5
votes
2answers
2k views

ScriptResx.ashx Not Working

I'm trying to use ScriptResx.ashx in an Application Page I'm building (just to test out the functionality) and every time I try to grab a resource from what should be a JavaScript object, SharePoint ...
5
votes
2answers
3k views

Datetime update is one day off

I'm updating a list with a date field (just the date) using the ECMASCRIPT object model but when the date is inserted is one day off from the introduced date, It's literally making me pull my hair off ...
5
votes
2answers
3k views

How to disable a ribbon button when a folder is selected

I have added a new button to the SharePoint ribbon for document libraries. This all works well and the button is enabled / disabled depending on the number of items selected... fine! I want to ...
5
votes
3answers
11k 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 ...
5
votes
1answer
333 views

SharePoint 2010 - Using REST to validate unique list item

I'm attempting to validate that a duplicate combination of staff (person/group field) + parent ID (lookup field) does not already exist in a list. Below you can see that I've added an ajax call to the ...
5
votes
3answers
4k 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 ...
5
votes
5answers
2k views

Include JavaScript in a feature

I remember seeing somewhere that you can include an external JavaScript file in a SharePoint feature if it is in the _layouts folder. For the life of me I can't remember how to do this!
5
votes
2answers
342 views

Reliably get attachments for list item

I'm working with SP2010's SP.js and I need to get all the attachments of a list item. As it's SP2010, I don't have access to SP.ListItem's attachmentFiles property. :( The following code works for ...
5
votes
2answers
744 views

ctx in CSR not return the title

I need to make by clicking on the title of a list item, to open the edit form and not the view form. To do this I chose the CSR, I have the code: (function () { var statusFieldCtx = {}; ...
5
votes
1answer
395 views

SP.UI.Status anonymously inaccessible

Using Office 365 (SharePoint Online) I have stumbled into an annoying thing. Some parts of the JavaScript CSOM does not seem to be accessible when your browse the site anonymously. If Firstly I tried ...
5
votes
1answer
8k views

How to authenticate user in sharepoint online using javascript

I have a public site on Office 365 SharePoint Online. By default when user clicks on to sign in, it redirect to Microsoft login page. I don't want to redirect user to Microsoft login page. But ...
5
votes
3answers
1k views

Unable to set “End Time” of Calendar through Javascript

I am trying to set default value of "End Time" field in Calender NewForm.aspx page. Here is my code: var txtDate = $("#" + $("label:contains('End Time Date')").attr("for")); var cboHours = $("#" + ...
5
votes
3answers
5k views

How to get SP.Folder for SP.ListItem in SharePoint 2010 JavaScript Client Object Model?

I have a custom button on ribbon for document library and need to disable it if current SPListItem is an empty folder. To disable button I use EnabledScript attribute of CommandUIHandler. I can get ...
5
votes
5answers
7k views

Retrieve All list items with AngularJS and ClientContext

I would like to ask you if there is a possibility to use ClientContext with AngularJS? In this way I want to take all items, sort them, filter, make some modification and etc. Later maybe I will add ...
5
votes
1answer
4k views

“The XSS Auditor refused to execute a script in…” from Chrome when using <script> tag in content editor webpart

Embedding javascript in a content editor web part triggers XSS Auditor error in Chrome when editing any webpart on the page containing the content editor web part. Steps to reproduce 1 - Use newest ...
5
votes
3answers
2k views

Updating a Property w/ 2013 REST Api

I have a sharepoint hosted app that is succesfully able to add Read and Create files on the Host site (using the REST Api and SP.RequestExecutor). Now I am trying to figure out how to update ...
5
votes
1answer
170 views

Check if web is in pagepreview mode - ?pagepreview=true

How can I check if a page is in ?pagepreview=true mode? I've branded the sharepoint ribbon and need to check if a page is in pagepreview to get the site branded correct (js / css). Is there a way to ...
5
votes
2answers
2k views

Sharepoint page redirection using JavaScript

below I have some JavaScript which listens for mouse activity and starts a timer if there is no activity and then redirects the user to another page after say 2 minutes..The problem is that if I have ...
4
votes
3answers
3k views

how to determine if a page is checked out? Client side, using javascript?

I need a way to determine if a publishing page is checked out by the current user; I need this because I'd like to put a redirect, if the page is not checked out. Any ideas?