Tag Info

Hot answers tagged

3

I guess you want to fetch List items using REST Api. Below is the endpoint for REST. <site URL>/_api/lists/getbytitle('listname')/items If you want more details, you can look into below URL, which is fetching data from SharePoint List using Javascript and REST API: ...


3

In SharePoint the "page" is actually inside of a DIV and the window really never scrolls... The content inside that DIV does scrolls (unless you have a customized branded site). So although your code will work on a standalone HTML page, it will not in a standard Sharepoint site (2010 and above)... See the solution I posted here to a similar question. ...


3

You could try the following method to determine whether a document set exists. How to find a Document Set via JSOM function getDocSet(listTitle,docSetName, success,error) { var context = SP.ClientContext.get_current(); var list = context.get_web().get_lists().getByTitle(listTitle); var items = list.getItems(createGetDocSetQuery(docSetName)); ...


3

var clientContext = SP.ClientContext.get_current(); // Gets current site context var id = GetItemID(); //retrieve selected list item id to update data var listId = SP.ListOperation.Selection.getSelectedList(); var oList = context.get_web().get_lists().getById(listId); this.oListItem = oList.getItemById(id); function GetItemID() { var selectedItems ...


2

First of all, SP.List.getItems Method returns SP.ListItemCollection object not an SP.ListItem object. Second, in your case you have to submit first query in order to retrieve item collection and then only to get the item and delete it, for example: var items = list.getItems(query); context.load(items); context.executeQueryAsync( function() { ...


2

You are attempting to use a SP.ListItem method on a SP.ListItemCollection object. SP.List.getItems() returns a SP.ListItemCollection object. You must iterate through this to get to the items themselves. Try the following: function deleteListItemSP(title){ var siteUrl = 'mylink'; var clientContext = new SP.ClientContext(siteUrl); var oList = ...


2

These other answers tend to be too simple or way too complicated... ;) This should do what you want, you just might need to change the url variable and the select parameters to conform with your environment -- but I took my best guess based on the information you provided. You could also remove the jQuery reference if your page already has it. Here is a ...


2

Depending whether taxonomy field is single-valued or or multi-valued use the corresponding method: single-valued taxonomy field: SP.Taxonomy.TaxonomyField.setFieldValueByValue by specifying SP.Taxonomy.TaxonomyFieldValue object multi-valued taxonomy field: SP.Taxonomy.TaxonomyField.setFieldValueByValueCollection Method by specifying ...


2

The specified error could occur due to one of the following reasons: Column with Internal Name Value does not exist in the List Configuration Values Since SP.ListItem.item property expects field Internal Name, please make sure the field with such a name exists in List. List Item value for a field Value could not be loaded implicitly. Try explicitly ...


2

Since you have already tagged the question with client-side-rendering tag, I would recommend you to consider a slightly different approach. As you might guess the solution described below allows to highlight the row in List View using Client-Side Rendering (CSR) approach. Highlighting the row using CSR Template code: ...


2

SP.View.viewFields property returns field names but not a Field client objects. The following example demonstrates how to print field names in View. Working example: function retrieveFieldsOfListView(listTitle,viewName){ var context = new SP.ClientContext.get_current(); var web = context.get_web(); var list = ...


2

I think the style of script you're writing is probably fairly unique in the wild (how do you handle authentication if you're in the non-SP case and you use something like a REST request, for instance?) so you may not find a genuine 'standard' for doing this -- but checking for the SP object being initialized would be sufficient in most cases. If you wanted ...


2

If you look at the HTML SP renders for a peoplepicker you will see why your code is not working. But here's how you can attach an event to the onchange: $(".ms-usereditor div").bind('input propertychange', function() { alert("Onchange event" ); })


2

It looks like Microsoft have introduced the SiteLogoUrl property now within SPWeb in Office 365: http://blogs.office.com/2014/08/13/uservoice-driving-improvements-sharepoint-api/ and https://officespdev.uservoice.com/forums/224641-general/suggestions/6234945-make-the-sitelogourl-property-available-in-csom The <SiteLogoUrl> element is emitted from the ...


2

What you could do, is to override the function in Core.js on the current page instead. If its a library the actions are added in the AddDocLibMenuItems. And the View/Edit Properties are added from the AddShareNamespaceMenuItems function. So you could add this function to your page, just make sure its loaded after Core.js: function AddDocLibMenuItems(m, ...


2

In SharePoint 2013 was introduced new permission level Remote Interfaces Permission that in particular prevents anonymous users from accessing CSOM interface. How to enable CSOM for Anonymous Users Go to Central Administration Go to Manage Web Application Select your Web App Click on Authentication Providers in the ribbon Click zone "Default". Uncheck ...


2

Most probably the specified error occurs since you are trying to get site-level Content Type while web is not a root web. Quick fix Replace the line: var docsetContentType = web.get_contentTypes().getById(docSetContentTypeID); with: var docsetContentType = ctx.get_site().get_rootWeb().get_contentTypes().getById(docSetContentTypeID); How to ...


2

you can reference scripts in the masterpage of this forma: <SharePoint:ScriptLink language="javascript" name="custom.js" OnDemand="true" runat="server" Localizable="false" /> Referncing a java script inside my master page will not fire


2

I accomplished this by using the following als document link, if the user clicks it the document is opened in the online word viewer. Depending on your server configuration, this might not work for all file types. [site URL + Library location]/_layouts/WordViewer.aspx?id=[document URL]


2

For getting the pages you could utilize the same REST endpoint that is used for getting List Items, for example: http://<site url>/web/lists/getbytitle('<list title>')/items(<item id>) JavaScript Example function getListItem(webUrl,listName,listItemId, complete, failure) { $.ajax({ url: webUrl + ...


1

It could be a scoping issue, that your function is only being defined inside the scope of the display template rendering. Try this: <a title="_#= $htmlEncode(Srch.Res.sb_GoSearch) =#_" class="ms-srch-sb-searchLink" id="_#= $htmlEncode(searchBoxLinkId) =#_" onclick="window.CustomFunction();" href="javascript:void(0)"> <img ...


1

When you save a list as a template, it will not preserve the lookup column as the IDs of the source column from which it looks up might change causing the lookups to break. There are a couple of workarounds which you can try. Try this and this


1

You can add you javascript code to NewForm.aspx. Place this code in the newform.aspx page under the line <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server"> <!-- dkf code modified to redirect page end --> </div> <div class="mainContent"> <!-- dkf code modified to redirect page --> ...


1

You cannot permanently modify an aspx page on the SharePoint server using JavaScript in the browser this way... You could implement a flag value in the user's local storage if all of your users' browsers will support it -- or you could use a cookie to track if the user wants this particular item hidden. Then in each case on the page load you would check the ...


1

If you are making an async call, you are going to need to use a promise that needs to be resolved before returning true or false to the function. Pseudo code: function PreSaveAction(){ var somePromise = yourasyncfunction(); $.when(somePromise).done(function () { if (something == something){ return true; } else { return false; } ...


1

That means the RegisterStartupScript block is executing before your printModal function is defined. It was probably working in the application page because the function was defined before the script was getting called. You can fix this by just declaring your printModal function in the code-behind, using something like RegisterClientScriptBlock before ...


1

SharePoint 2010 and 2013 scroll within a div called s4-workspace not within the parent window. Based on looking at your script coming from 2003, I think this might need a major re-work... Here are some examples of other questions that have dealt with scrolling issues that have a lot of good background on how scrolling works in modern installations (since ...


1

Inspect the return results using your browser dev tools -- my environment (using O365 and jquery 1.11.1) returns the results from $.getJSON(url, function(data) { //do something with data }); in data.value no d, or d.results This works on my O365 site: $.getJSON("/_api/lists/getbytitle('Laptops')/items?$select=Title,Id", function (data) { html = ...


1

I'm not sure why $.getJSON() does not work, but $.ajax() should work: $(document).ready(function() { var oDataUrl = "siteURL/_api/lists/getbytitle('Laptops')/items?$select=Title,Id"; $.ajax({ url: oDataUrl, type: "GET", headers: { "Accept": "application/json; odata=verbose", "Content-Type": ...


1

You can get the list url from the get_defaultViewUrl method... when you load the lists you need to use the include statement to retrieve the defaultViewUrl property (it isn't included with the list results by default). Change your context.load line to: context.load(lists, 'Include(Title,DefaultViewUrl)'); Then inside of your iterator loop you can use ...



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