New answers tagged

1

The SP.SOD.executeFunc function will always return undefined, as most SharePoint JS functions that run asynchronous code do. The third argument, your getPageTitle callback function, can be declared to return something, but that something cannot be captured by the SP.SOD.executeFunc function to be able to do var par = SP.SOD.executeFunc('sp.js', 'SP....


1

SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function(){ var par = getPageTitle(); //Do the rest of your logic here }); The third parameter is a callback function. The SP.SOD.executeFunc call doesn't actually return the value of your callback function. So you can supply your own callback function as above and do whatever you like (including ...


0

If you are on SharePoint 2013/Office 365 check if minimum download strategy is enabled for the site. Disable it and have a try.


1

Use $(window).load(function() {}); instead of document.ready(). It seems your DOM is loading after you are calling the function. window.load will run after all DOM has been loaded completely.


0

You might want to use _spBodyOnLoadFunctionNames.push method instead of jQuery's document.ready(), read this article. Also, other functions available.


0

Here is the working solution - Step 1 - Edit the Library Page and Add Script Editor Web Part . Step 2 - Paste the Below Code in web part for hiding the required button from ECB Menu Item using the Button ID (Replace ID value after # ). <style type="text/css"> li.ms-core-menu-item #ID_DeleteDocItem, .ms-core-menu-separator hr { display:none; } <...


0

Instead of adding code in Content Editor WebPart add in Script Editor WebPart. In Script Editor WebPart add following code. Create formaction.js file and add your js code in this file. Add script editor WebPart after your display form WebPart. Give reference of jQuery plugin Create formaction.js file give reference of that file after jQuery reference. ...


2

For People picker field you have to get the html element using below snippet function PreSaveAction(){ SP.SOD.executeFunc('sp.js', 'SP.ClientContext', ValidateUser); return true; } function ValidateUser(){ var pickerDiv = $("[id$='ClientPeoplePicker'][title='<Field Name>']"); var peoplePicker = SPClientPeoplePicker....


1

For a people selector, try something like$("input[id^='YourPeoplePicker']").val() For a RTE, try something like var comments = $("div[id^='Richtextfield'].ms-rtestate-write").html().length; You really need to start leveraging the dev tools of your browser and use the jQuery help documentation, it is really helpful.


0

1) Your listItemsA variable is not set as a global variable, therefor the listItemsA might not exists within your success function. 2) Because the success function an async function it will mean that your cycle method can execute before the query has been succesfully retrieved. And the slidehsow ill start without your data present I would place/execute the ...


1

It is not totally clear whether you want to write the value to the list or just display the value. So here is another solution which only displays the value without actually writing it to the list: ExecuteOrDelayUntilScriptLoaded(sum, "inplview.js"); function sum(){ ReRenderListView_old = ReRenderListView ReRenderListView = function(ctx){ ...


1

You can get total of the current view from ctx.ListData.Row. var total = 0; ctx.ListData.Row.forEach(function(item) { total += item["column1"]; }); Then update the column2 using REST API function updateItem(url, oldItem, newItem) { $.ajax({ url: _spPageContextInfo.webAbsoluteUrl + url, type: "PATCH", headers: { ...


0

Wrap the anonymous immediate function in a document ready function like so... $(document).ready(function(){ var subsiteUrl = "site/subsite" (function($j) { ExecuteOrDelayUntilScriptLoaded(doWorkA, "SP.js"); function doWorkA() { var currCtxA = new SP.ClientContext(subsiteUrl); ... })(jQuery); });


1

Not so trivial after all. I played around a bit and here is what I came up with: Notes first: You will need jQuery (at least on the DispForm.aspx of the Training Calendar list and on the NewForm.aspx of the Registration list) You Registration list needs a lookup column to the Training Calendar list You will have to deactivate Minimal Download Stratgy on ...


0

Since the field is a Rich text multi-line field, if you look into the DOM (using Firebug or IE tool) there would be some values in it. like empty < p> tags. Try the following: function stripHtml(body) { var regex = /(<([^>]+)>)/ig; var result = body.replace(regex, ""); return result; } var textFieldHtml = $("div[id='...


0

I suggest you to use this code $("input[title='your field name']").val() to get text value for best practice. Because text field ID is dynamically generated id in SHAREPOINT and return true at end of the method your code should be var j = jQuery.noConflict(); function PreSaveAction() { var txtTitle = $("input[title='your Application ield ...


1

You have two problems: Your txtTitle1 variable is equal to $.(. Just remove that dot after the dollar sign. Your Description field seems to contain rich HTML because the field ID in the DOM contains the word _inplacerte at the end, therefore the value() jQuery function will not work since the field is not an input or textarea element, but rather a DIV ...


1

Here this code will work only in case of 2 fields available in your list. It will not work for more or less than 2 fields. Reason: CAML you are formatting is wrong. While building a CAML query it should be always in pair of 2 conditions CmalQuery += "<View><Query><Where><Contains><Or>"; while (e.moveNext()) { ...


1

Remove ' from the query and try like this CmalQuery += "<FieldRef Name="+fieldName+" /><Value Type=Text>" + txtValue + "</Value>"; Maybe this will work.


1

The below will return you the current value of the select field: $("select[title$='Phone Data Collection']").val() To put it as part of your logic you would do: if ( $("select[title$='Phone Data Collection']").val() =='SOME VALUE')


1

Try something like this: var count = 0; $("#UserOrgId").find("span.ms-RadioText > input").each(function() { if($(this).prop("checked")) { count += 1; } }); console.log(count);


0

This can be done by SPServices.SPGetCurrentUser User information list Use of SP.UserProfiles.js Refer this link for SPServices.SPGetCurrentUser Get user detail from userInforList here With help of UserProfile.JS here


3

You can do it in SharePoint 2010 by querying following end-point. /_vti_bin/ListData.svc/UserInformationList Add your required properties in $select operator. /_vti_bin/ListData.svc/UserInformationList?$select=Id,Name,.. Example using jQuery function getUsers() { $.ajax({ url: "/_vti_bin/ListData.svc/UserInformationList", type: "...


0

I found this solution and it works well for me. I do not have the Search Server Express as part of my SP Foundation 2010 installation, so I can't answer whether this will have any affect with it. This is also a jQuery solution, albeit a little longer. This code should be places before the closing tag. <script type="text/javascript" src="https://code....


0

You can have only one $(document).ready in your html but jquery provides another way to handle this for multiple function calls on page load. Use this: $(function(){ function1(); function2(); function3(); }); Here $(function(){ ... }); is equivalent to $(document).ready but the advantage is that you can call more than one function from within it or ...


2

Remove "." from your code at line number 3 i.e j(":input[title='Application Name']").val(); var j = jQuery.noConflict(); function PreSaveAction() { var txtTitle = j(":input[title='Application Name']").val(); alert(txtTitle); if(txtTitle == ''){ alert("Value Cannot be Blank"); return false; } else{ return true; } ...


0

Try this code, ites working for me <script type="text/javascript"> var j = jQuery.noConflict(); function PreSaveAction() { var txtTitle = j("input[title='Application Name']").val(); alert(txtTitle); if(txtTitle == ''){ alert("Value Cannot be Blank"); return false; } else{ return true; } } </script> Use ...


0

Try this: function PreSaveAction(){ var txtTitle = $("input[title='Application Name']").val(); alert(txtTitle); // ... };


0

The simplest way to achieve it is using SharePoint Designer Workflow, Say you have a Document library with name 'Test Documents' and Promoted links list as 'Latest Document Link' Create a SharePoint Designer Workflow for the 'Test Documents' Library Set the 'Start Option of the Workflow' as 'Start Workflow when an item is created' In the Workflow, Update ...


0

Your code will only work if you Update ALL Items EVERY day As explained in: How to use Today and Me in Calculated column You have to do the Today comparison in the JavaScript code I whipped this up quick, works on a standard Task List. function ColorCodeDueDate(ctx) { var fieldname=ctx.CurrentFieldSchema.RealFieldName, datevalue=new Date(ctx....


1

Try this code SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() { SPClientTemplates.TemplateManager.RegisterTemplateOverrides({ OnPostRender: function(ctx) { var calcColors = { 'Yes' : '#FFFFFF', 'No' : '#FF0000' }; var rows = ctx.ListData.Row; for (var i=0;i<rows....


0

Typically, i find the oslo.master or seattle.master and edit the master page, you can find in your SharePoint Design Master Page on navigation menu, this option show all masterpages in your site, and click on seattle or oslo and edit file in advanced mode. I strongly advise you to make a backup of one of the two and modify your backup. Like this exemple.


0

From SPD -> All Files -> _catelogs -> masterpage This will give you all html files.


0

Try putting this into your script editor web part or place it all in a .txt file and reference to it using a content editor web part (I find this way easier to work with). You'll have to modify the HTML to whatever parts you are using. <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script> <script type="text/...


0

You should use SPClientPeoplePicker - default JS object for SP2013. More info see there: Get the ID and Name from multiple Client side People pickers to store in a list Using SPClientPeoplePicker you can read members, write member, use groups and filters


0

Here you go: var RequestedForpeoplePicker = this.SPClientPeoplePicker.SPClientPeoplePickerDict.RequestedFor_TopSpan; var RequestedForu = RequestedForpeoplePicker.GetAllUserInfo(); and my peoplepicker <div> <SharePoint:ClientPeoplePicker Required="true" ValidationEnabled="true" ID="RequestedFor" UseLocalSuggestionCache="true" ...


1

Add this below given code in a CEWP (Content Editor Web Part). <script language="javascript"> function Custom_AddDocLibMenuItems(m, ctx) { var strDisplayText = Redirect to form here; var strImagePath = ; var strAction = 'window.navigate(/.../editform.aspx?Source= document.URL.substring(0, document.URL.indexOf(/Forms, 0)) ?RootFolder= GetUrlKeyValue(...


1

You can add Custom Action for list items using JavaScript. You have to set the appropriate document URL as a link. Adding a User Custom Action for List Items Using Javascript


3

I had a similar requirement sometime ago. Due to browser compatibility issues, I ended up using window.prompt, shifting the control of the copy/paste functionality over to the user: window.prompt ("Copy to clipboard: Ctrl+C, Enter", text); BTW, the text will already be selected, so the user simply has to press CTRL+C. At the time I believe this is where ...


0

I solved it. This can be achieved in 2 ways: $(document).ready(function() { var soapEnv = "<?xml version='1.0' encoding='utf-8'?> \ <soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> \ <soap:Body> ...


1

This code is of retrieving user properties of current logged in user. you can read more in this article of how to modify the below code to obtain what you need. (function($){ $(document).ready(function(){ // Ensure that the SP.UserProfiles.js file is loaded before the custom code runs. SP.SOD.executeOrDelayUntilScriptLoaded(loadUserData, ...


1

SharePoint 2013 provides the SPClientPeoplePicker API to interface with the people picker. http://ranaictiu-technicalblog.blogspot.kr/2014/11/sharepoint-2013-client-side-people.html //Works with SharePoint 2010 $("div[title='People Picker']").text(strUserName); //Works with SharePoint 2013 try { //SharePoint 2013 ...


0

Below is the combined code using Client Object Model and jQuery calendar events carousel. You will get the idea from below code that how you can retrieve and display Sharepoint calendar events using Javascript. <html> <head> <style> .myUL { list-style: none; padding: 0; margin: 0 auto; width: 42em; height: 24em; } .myIL { height: 20em; ...


0

using Jquery should by $(xData.responseXML).SPFilterNode("z:row").each(function() { var text = $(this).attr("highriskCountries") $("select[title='country1']").append($('<option/>', { value: text, text: text }) }); Greetings


0

Kindly refer to the attached code using SPServices to bind drop down list. <script src="/_layouts/divy/Scripts/jquery-1.7.min.js" language="javascript" type="text/javascript"></script> <script src="/_layouts/divy/Scripts/jquery.SPServices-0.7.0.js" language="javascript" type="text/javascript"></script> <script type="text/...


0

You can do this with OOB infopath checkboxes, I"m not sure about DropDowns though. Add your list as a data connection. And then create a field for each particular time slot. call it something like "CountTimeSlot1" and etc for all of the time slots. Then set the value of each field equal to the formula Count(find your field in the data connection section and ...


-1

I got the reference of this STACKOVERFLOW LINK You can do it with IE 'sometimes' as I have done this for an internal application on an intranet which is IE only. Try the following: function GetComputerName() { try { var network = new ActiveXObject('WScript.Network'); // Show a pop up if it works alert(network.computerName); ...


0

I got the solution, here is it that may help others in the community - In the below code, I have modified the TEXT Value: ALL with the same value and added Hyperlink. <script type="text/javascript"> // Check the main container is ready $('#WebPartWPQ2').ready(function(){ // Get each div $('#scriptPagingWPQ2').each(function(){ // ...


2

First add a CEWP and add in this: <a onclick="goToAnchor('anchor')" href="#anchor">Anchor</a> <script> function goToAnchor(anchor) { var loc = document.location.toString().split('#')[0]; document.location = loc + '#' + anchor; return false; } </script> And down below where you want to go to (Slide to), add another CEWP and ...


0

To open the link inside browser has many scenarios, if the browser is google chrome, it automatically opens the PDF file within the browser, while I.E. pops up to download the file. If you have office web apps installed within the FARM all the links will be opened in browser only.



Top 50 recent answers are included