Questions tagged [javascript]

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.

1,320 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
1answer
334 views

How to get the subsite url from an image url in SharePoint Online using JavaScript?

I have a list of urls pointing to images, which are originated in various subsites - sometimes burried in nested folder structures. Now, my question is: Is there any way I can derive the url of the ...
2
votes
0answers
36 views

SharePoint Survey Countdown and Click Next

We have an OOB SharePoint Survey that asks a question and if the user doesn't answer in 20 seconds, we want the survey to advance to the next question. We have a Script Editor snippet.. and if we ...
2
votes
1answer
73 views

Returning results from a SharePoint list using Javascript code

Going round in circles. I'm trying to return results from two columns on a SharePoint list pictured, which will return the results to a HTML page which is being created by a different JavaScript ...
2
votes
0answers
728 views

SP.Utilities.Utility.SendEmail send as plain text

I'm using the SendEmail JavaScript utility and it's working except that I'm getting the email as HTML instead of plain text (which is what I need to process the body correctly for another service). I'...
2
votes
1answer
249 views

Count checked out files in sharepoint 2010 library using javascript

The checked out files can be reached via the UI by browsing Document library --> settings --> Manage Checked out Files. I would like to do it using the usual "function, success, failed" procedure in ...
2
votes
0answers
84 views

Display Modifications Each Time an Item is Updated

Not sure if this can be accomplished, but I want to try. Objective: When an item is modified SharePoint keeps track of the modification date, time, and person who modified the item. You can see ...
2
votes
0answers
18 views

How does one search a site collection for code embedded in web parts?

When refactoring you have to search your code base to see what areas may be impacted by a changing api. Code that is maintained in .js files and checked into source control can easily be searched. ...
2
votes
2answers
385 views

Countdown html/css/js not working but works in jsfiddle

Is there any reason why this solution won't work in SharePoint? It works well on jsfiddle. I modified the html file to add css and js reference and put the html in a cewp. What am i missing? any help ...
2
votes
0answers
293 views

Unable to change the field type for “People or Group” from the built-in text field to be a drop down list

I have read the following article which shows how to change a "People or Group" field type from text field to be a drop down, which what i am looking for:- https://hyankov.wordpress.com/2015/07/15/...
2
votes
0answers
168 views

Create dynamic view of list item by clicking on tile

I have a "promoted links" list to display some tiles on a page. What I am trying to do now is to display a popup window or a seperate browser window when I click on that tile, based on the list ...
2
votes
0answers
434 views

Type Error: Cannot read property 'push' of null while creating Cascading Dropdowns

I am getting the Type Error: Cannot read property 'push' of null in the SPServices js file while implementing Cascading Dropdowns. I am including the js files jquery-1.10.1.min.js and jquery....
2
votes
0answers
40 views

Site JavaScript optimization with JavaScript compression

I have a site with many webparts created in visual studio, each webpart is referencing a JavaScript file, and I have some pages with 5 or 6 webparts. Whats the best practice to do compression for ...
2
votes
1answer
104 views

Add same webpart multiple times on a webpage

I have a webpart i need to add multiple times on a webpage, how can I restrict in javascript the the variable to read from each webpart property? In webpart ascx file, I have hidden fields like: &...
2
votes
0answers
44 views

How to open a default Document library and upload files from it when clicking Choose file option?

How to upload files from default Document Library when clicking on Choose file INPUT control? When clicking on the "Choose file" it should open Document Library, from which I could select documents ...
2
votes
1answer
480 views

SharePoint custom JavaScript and jQuery blocked by MDS Minimal Download Strategy

Here's my setup. Onprem SharePoint 2016. I have a master page which is basically a copy of seattle.master and I want to add jQuery and a custom Javascript to manipulate the DOM. The minimal download ...
2
votes
0answers
177 views

How to open one EditForm.aspx Page in Classic mode, In a Modern Experience SPOnline env.

I do not want to switch the whole SiteCollection back to Classic. Users are very happy with the Modern Experience I want to open the EditForm in Classic mode only once.. so my UserCustomAction ...
2
votes
0answers
31 views

Is it possible to POST to a list that requires OAuth, through just js?

I'm (very) new to SharePoint, and have been tasked with creating what was described as a "lightweight Angular form" to submit items to a list. The form is supposed to be embedded into a page, so it's ...
2
votes
1answer
2k views

Grouping SharePoint REST API results

I am building a customized events feed via REST query. I have a feed of all events in the calendar, filtered on date range and sorted, but I'd like to take it a step further and group the results by ...
2
votes
0answers
753 views

group by and count in caml

I need to create chart using JavaScript from SharePoint 2010 list data .I am stuck to create data structure. Status: Pending Department: XYZ Number-row:10 Please help me to create caml query ...
2
votes
0answers
891 views

check if User field value is a user or a group using CSOM/JSOM

I am able to get a user field and its value from a list using CSOM/JSOM. I cannot figure out how to get if the value is a user or a group. ExecuteOrDelayUntilScriptLoaded(function() { var context ...
2
votes
0answers
47 views

Prevent Visual Studio from Overriding Poject internal SPList

Is there a way to prevent Visual Studio from Overriding Poject internal SPList? And how can I reuse a already created List inside an App? The Lists is not accessible after a new deployment of the app....
2
votes
1answer
478 views

Open SharePoint Modern library in modal dialog not adhering to ms-dialogHidden or IsDlg=1

Question regarding Modern Libraries, I wish to open document libraries in a Modal Dialog on a page but have only the library shown, not the Office 365 Suiter bar and left nav. I used the standard SP....
2
votes
0answers
2k views

getting XMLHttpRequest cannot load (URL) Response for preflight is invalid (redirect)

here am trying to get reccurring events from calendar list for sharepoint Online app and there am using code as like hostWebUrl = decodeURIComponent(manageQueryStringParameter('SPHostUrl')); ...
2
votes
2answers
211 views

Unable to get event item time in SharePoint online calender list

I'm writing simple JavaScript. In that script I'm getting Event item Start date field value and End date field value from Custom calendar list. but the code retrieve different time Example: here is ...
2
votes
0answers
272 views

Create site collection using jsom

I am wondering if creation of site collections with javascript on SharePoint hosted sites, is still not possible? If not, is it possible to use the site collection creation form _layouts/15/online/...
2
votes
0answers
126 views

starting JSOM workflows 2013 Invalid request / unauthorised

I have trouble starting workflows with JSOM. The first case causes errors only for some users mostly on Wi-Fi First case is : var servicesManager = new SP.WorkflowServices....
2
votes
1answer
33 views

how to start workflow when list item got added in SharePoint hosted app list

I want to start workflow when list item will be get added into my SharePoint hosted list using javascript?am very new to this.
2
votes
1answer
462 views

Resize an Image Before Upload to SharePoint List using REST API

I'm uploading an image to a SharePoint list using the REST API based on documentation here. My function looks like: function uploadFile(FormDigest, FileInput, fileName) { var ...
2
votes
1answer
541 views

SP2010: Compare the value of a date column with today's date

I've a column D in a list of type Date and Time which takes only date values (not time). I want to write a javascript function to check if the value in D is less than today's date (only date, not time)...
2
votes
1answer
362 views

Type is undefined: Javascript error that occurs in new environment but not the old

I am building a new VM for Development. In my Production environment I have a page that throws no errors and works correctly. However, when I try to look at this page in the new VM, I get the error "...
2
votes
2answers
421 views

Add default value to the site column inside content type using javascript Sharepoint 2013

I am creating some site columns using javascript. And also I am creating content types. I am attaching these site columns to the content type with the <FiedRef> tag. But I want different default ...
2
votes
0answers
31 views

Display Multi-field Checkbox

I have a MultiField Choice list item. By default it displays: Choice 1, Choice 2, Choice 3, Choice 4, I would like it to display like the following. Choice 1, Choice 2, Choice 3, Choice ...
2
votes
2answers
399 views

Script Not Working for User With Read Permissions

I have a workflow that sends emails out. When a user receives the email, there is a hyperlink called Review. When user clicks on Review, the value of the column called ReviewStatus on the Improvement ...
2
votes
1answer
304 views

Color Row if Date in column = Sysdate in SharePoint Foundation 2013 using CSR

I´m using a List with about 400 Rows, for each day one. Now i want to color each row where the Date is a Day of Weekend (Sat & Sun). This Part is wokring fine with this JS var statusColors = { '...
2
votes
1answer
220 views

Insert JavaScript automatically to new pages added to SharePoint wiki library

I wanted to Insert JavaScript automatically to new pages added to SharePoint wiki library. Instead of users manually adding the script to each page, it should be present by default or added ...
2
votes
0answers
753 views

Managed Metadata Global Navigation

I’m using managed metadata to create global navigation on a SharePoint Master Page. I understand that a managed metadata term set can only be applied to a single site collection. To bypass this I’m ...
2
votes
0answers
432 views

Correct usage of getListItemChangesSinceToken() in JavaScript

I'm working on a Sharepoint hosted App, that accesses List Data from the Hostweb as I outlined here: EventListener for List changes in Sharepoint Hosted app I want to use the ...
2
votes
0answers
55 views

Collection has not been initialized(async)

I am trying to create with search(display templates). To return a list with only the followers. The following error is throwing when running: "Error: The collection has not been initialized. It ...
2
votes
1answer
144 views

Javascript object model says load succeeded, but object is empty?

I've got a pretty weird issue going on on a clients SharePoint 2013 environment. We're using some JSOM javascript code to retrieve details from a web. Here is a snippet of the code: function ...
2
votes
0answers
214 views

Starting List Item Workflow using Javascript on custom edit page

I have a custom edit page with some Javascript inserted using a CEWP. From this page I am calling a function to start a list item workflow on the current item being edited. I am using the following ...
2
votes
2answers
65 views

Trouble updating rows of data in an External Content Type using Javascript

I've tried a few different ways of doing this, including querying the External Content Type and then updating the current item. However as far as I ever get is an undefined variable error. This is my ...
2
votes
1answer
877 views

Remove list item permissions by role type using JSOM

I'm looking for a good way to remove all list item permissions on a certain list item of a specific role type using the JavaScript object model. With myListItem.get_roleAssignments().getByPrincipal(...
2
votes
1answer
86 views

Sharepoint 2013 - show edit to admin only

I hope this has not been asked before (I did a few search's on here first). I need to be able to only show the Blue & Grey SharePoint Bars to admins - for all other users I want to be able to ...
2
votes
0answers
201 views

how to add a link to a document using rest api

Please help me in adding a "Link to a document" using rest api to document library
2
votes
0answers
454 views

Sort ListView via Postback in JSLink file

I found out, that you can filter a list view in a JSLink File very easy by a postback: function filterList(ctx, filterField, filterValue){ __doPostBack(controlId, 'NotUTF8;__filter={' + ...
2
votes
1answer
37 views

Top visited entries on site collection blogs

I want to develop a web part which shows the ranking of entries of a site collection. By now, I think a way to do this is to use a Javascript code added on the master page which adds a row to the ...
2
votes
1answer
235 views

Display image(preloaders) before content is loaded WebPart - SharePoint 2013

I'm using a plug-in called lightSlider and I notice it doesn't display the whole content on first load until I refresh. I have tried using 1. windows.load, 2. ExecuteOrDelayUntilScriptLoaded, 3. ...
2
votes
2answers
1k views

Prerender executing twice

I have some prerender code that is being used to get information from another list to add into the display of the main list. I am puzzled - the prerender code executes twice. (function () { var ...
2
votes
0answers
72 views

CSR - One function for every field in a View?

We all know how to define one template function for one field. SPClientTemplates.TemplateManager.RegisterTemplateOverrides({ Templates: { Fields: { "[fieldname]": { ...
2
votes
0answers
39 views

What are the different ways to consume SharePoint REST using Javascript

I know of two ways, using ajax and using SP.RequestExecutor.js. Are there any other ways. Code snippet and information around performance will be appreciated.