Hot answers tagged

37

Since your "today" variable is a JavaScript date object, you can get the string representation by calling the toISOString() method. ...$filter=StartDate ge datetime'" + today.toISOString() + "' and ...


22

The log file should get you the path that SharePoint unsuccessfully tries to resolve. Try adding "~sitecollection" first in the ScriptLink like: <SharePoint:ScriptLink language="javascript" name="~sitecollection/custom/jquery-1.10.2.min.js" runat="server" Localizable="false" /> but this will only work inside the "the_new_osce_portal" Site collection....


17

I answered the question here (not exactly a duplicate, since that was in regards to the Search REST API, and I happened to give an answer for basic REST). Here is how you filter dates in REST: $filter=StartDate ge datetime'2014-01-01T00%3a00%3a00' This filters for items created after 01-Jan-2014, 00:00:00. So to filter between two date ranges, simply add ...


16

I imagine your script does not work because of the src attribute on your link to jQuery, it should probably look like this instead: <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script> But what you can do instead is this: Each promoted link seems to be 160px wide, so why not just limit the whole "box" to x ...


15

They have a JavaScript API for this: http://msdn.microsoft.com/en-us/library/office/ff408647(v=office.14).aspx You can even add command ui extension like you have them. var context = new SP.ClientContext.get_current(); this.site = context.get_web(); var customAction = this.site.get_userCustomActions().add(); customAction.set_location('CommandUI.Ribbon....


14

You can't update field values in the same call that uploads the document, you have to do that in a separate call. The response from the call that uploads the document will be a SP.File object representing the file that was just created. This object will have a deffered property called ListItemAllFields, which you can use to get the URL needed to make a call ...


13

Probably the most simple way to hide View header would be to use CSS 1 Add Content Editor web part on View page (located under Media & Content category) 2 Insert the following code into Content <style type="text/css"> .ms-viewheadertr { display:none; } </style>


13

scenario: when you enter form editing and has some user of this picker people, this is the "oldHtml"? (I'm finding this a bad practice) try using this code: var getIDPeoplePicker=$("div[Title='Column Name of the people picker here']").attr("id"); var ppobject = SPClientPeoplePicker.SPClientPeoplePickerDict[getIDPeoplePicker]; ...


13

Like I mentioned in my comment, a simple workaround would be to traverse through the json results and delete the Title for each var call = $.ajax({ url: "http://<site url>/_api/web/lists/GetByTitle('ListTitle')/items?$select=*" ,type: "GET", dataType: "json", headers: { Accept: "application/json;odata=verbose" } }); call.done(...


12

Document ready event gets fired when the DOM get loaded. This doesn't necessarily guarantee that the JS files required for SharePoint JSOM is already loaded. The best way is SP.SOD.executeFunc('sp.js', 'SP.ClientContext', readyFunction); function readyFunction() { Function1(); Function2(); Function3(); }


12

I have tested it out and was able to do it using CSR and JS Link. Save the below code to say:projectCode.js and upload it to site assets and then refer it in the JS Link of the list view : (function () { var overrideCurrentContext = {}; overrideCurrentContext.Templates = {}; overrideCurrentContext.Templates.Fields = { 'ProjectCode': { 'View': ...


10

If you just need to access the values, you could do it like this: var dispTitle = "APickerField"; var pickerDiv = $("[id$='ClientPeoplePicker'][title='" + dispTitle + "']"); var peoplePicker = SPClientPeoplePicker.SPClientPeoplePickerDict[pickerDiv[0].id]; peoplePicker.GetAllUserInfo(); The GetAllUserInfo() returns an array with one index pr ...


10

Have you tried to set keywordQuery.set_trimDuplicates(false); (MSDN) because maybe some rows / items are incorrectly treated as duplicates by search?


10

You need to call close() on object returned from showWaitScreenWithNoClose(). This works for me: var loading = SP.UI.ModalDialog.showWaitScreenWithNoClose(SP.Res.dialogLoading15); loading.close();


10

To average multiple columns in an item, you'd use a calculated column such as =AVERAGE([Column1],[Column2],[Column3]). To average a column, edit the view and expand the Totals section. By your column name, if it's a number, you can select average (etc) from the dropdown.


10

Your code should be worked, Just one note If you are using SSL, so you should use the HTTPS JQuery reference. The below code should work <script type="text/javascript"> $(document).ready(function(){ $('nobr:contains("Project Subtype")').closest('tr').hide(); //Show/hide columns based on Drop Down Selection $("...


9

You can use the JSLink property to load multiple files. Include a url to the jQuery file and you have a nice workaround. Please note that you will have to use a url within the same web application, you can’t reference the library from a CDN or similar. Try something like this: $Field.JSLink="~sitecollection/Style Library/MicrosoftAjax.js|~sitecollection/...


9

In the 2nd statement you should have used the site collection specific TOKEN as in: <SharePoint:Scriptlink runat="server" Name="~sitecollection/Style Library/[YOUR SITE]/PathToJqueryLib/jquery-1.10.2.min.js /> The issue with your 3rd (also known as Client-Side JavaScript library reference) is that such constructs do no recognize token-based ...


9

Use _spPageContextInfo in your JavaScript. Usage: var url = _spPageContextInfo.webServerRelativeUrl; alert(url); See others here: http://blah.winsmarts.com/2013-2-_sppagecontextinfo_is_your_new_best_friend.aspx


9

First, let's just clarify that JSLink is not equivalent to Client Side Rendering. JSLink is merely a property on SP objects that lets you attach Javascript files to them. However, the ability to attach a Javascript file to a SP object is enormously useful for CSR. Using the JSLink property is one of the easiest ways to apply CSR. And I would say that ...


9

This issue is related to ListItemEntityTypeFullName. ListItemEntityTypeFullName must be specified in __metadata. Your error message seems SP.Data.listnameListItem is not the valid value for ListItemEntityTypeFullName. This value can be found in the following end-point. /_api/web/lists/GetByTitle('listName')/ListItemEntityTypeFullName Make a GET request to ...


9

While Rothrock's answer is certainly valid, especially if you are using SP 2010, if you are on SP 2013 there's an even easier way. In SP 2013 there is a handy global function GetUrlKeyValue: var currentID = GetUrlKeyValue('ID'); You can of course use that to get any query string parameter (even custom ones you are inserting), provided you know the key.


9

You can do it using CSR as well as using javascript. Here i'm giving simple and easy javascript solution. Working Javascript solution: <script type="text/javascript" src="https://code.jquery.com/jquery-1.12.0.min.js"></script> <script type="text/javascript"> $(document).ready(function () { $("table[summary='YourListTitle'] td:nth-...


8

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" ); }); Update Here's a way which allows easy access/modification for all clientside peoplepicker ...


8

Any modern browser does not need jQuery document.querySelector("select[title='Destruction Approval'] option[selected]").innerHTML; Will do the same as your code But... radio-buttons are not a select with option elements... They are input elements with the checked attribute set for the selected radio-button document.querySelector("input[id^='Destruction ...


8

Extensive explanation, tutorial, etc.: Find Number of Users Currently Logged on to a SharePoint Site The gist of it is that you don't have OOTB features to show you the number of currently logged in users. You can check IIS for current users, but you don't know whether these are logged on or not. The solution explained in the blog article is to ...


8

You can try CSR concept. It will be applied to the List View Web Part, so you need to following script in all the places where you are using List View Web Part (if you are) otherwise, just follow the below steps. Open the List All Items view or the desired view. Now click on gear icon and select Edit Page. Now the page will be on edit mode, so you can ...


7

If the page the JSLink is on is not referencing jQuery and jQuery UI scripts, you will need to load them yourself. This can be done by for example: function loadScript(url, callback) { // adding the script tag to the head as suggested before var head = document.getElementsByTagName('head')[0]; var script = document.createElement('script'); ...


7

You could use REST and the CheckOut method. Altered from MSDN for jQuery and non-app approach: $.ajax({ type: 'POST', url: "/_api/Web/GetFileByServerRelativeUrl('<your file>')/checkout", headers: { 'X-RequestDigest': $('#__REQUESTDIGEST').val() } });


7

You call your method showWaitScreenWithNoClose using asyncronously with callback ExecuteOrDelayUntilScriptLoaded. If sp.js is not loaded, then closing event can fire before the wait dialog is showed. Your code should look like this: var waitDialog = null; function BuildTable() { ExecuteOrDelayUntilScriptLoaded(function() { waitDialog = SP.UI....


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