New answers tagged

0

i ended up with query below, works fine for me now, and i can search on LoginName, Title, or Email. `var userSearchSuggestionEndpoint = "/_api/web/SiteUsers?$filter=(substringof('" + searchKey + "',LoginName) or substringof('" + searchKey + "',Title) or substringof('" + searchKey + "',Email))"; return baseSvc.getRequest(userSearchSuggestionEndpoint)...


0

If you want to hook into MDS you might want use the official way with the asyncDeltaManager https://www.spcaf.com/blog/sharepoint-javascript-context-development-part-4-the-way-of-the-async-delta-manager/ Is a bit complex but has all the info http://blog.symprogress.com/2013/09/sharepoint-2013-execute-javascript-function-after-mds-load/ Is a good starter ...


0

Eval is Evil Oh My! Then you have to stop using SharePoint; as its code uses eval() in several places: sp.js uses it once: $v_0.MenuItems = eval($p1.get_executor().get_responseData()); core.js ... uses it 20 times !!! I will let you explore the other 15+ JavaScript libraries SharePoint loads into your browser yourself. The phrase Eval is Evil is ...


1

Please see the below example, you can use the "and" operator, to meet multiple conditions, http://{server_name}/_vti_bin/listdata.svc/UserInformationList?$filter=((ContentType eq 'Person') and (substringof(Name,'{query}')))&$orderby=Name Also, shared by Atish, on the following page, it shows you multiple other operators, you can use in your ...


2

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

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

You can easily use JQuery to get the filter by partial id. SPTextSlicerValueTextControl is the end of the ID of a SharePoint text filter input field. filterValue = $('input[id*=SPTextSlicerValueTextControl]');


1

For SharePoint Online / Office 365, you can use JSOM to make cross-site collection calls as long as the site collections are all in the same tenant. There are only two scenarios where you can make cross-site collection calls using the JavaScript Object Model in a SharePoint on-premises farm: Both site collections are located in the same web application ...


3

I've not provided whole code but you can call cross site connection using JavaScript. Take a reference from below code: var crossSiteContext = new SP.ClientContext("http://url-of-another-siteCollection/"); var crossSiteWeb = crossSiteContext.get_web(); crossSiteContext.load(crossSiteWeb); crossSiteContext.executeQueryAsync(function(){ var ...


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

You can use Infopath or Client Side Rendering (JS Link) for hiding the columns of the SharePoint List. for better understanding follow this blog using CSR https://code.msdn.microsoft.com/office/CSR-code-samples-11-Fully-54ebcaa6 To understand CSR well, you can follow this link Client-Side Rendering/JS Link documentation?


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

Nothing wrong with using JavaScript. Almost everything in SharePoint (frontend-wise) is handled with JavaScript anyway. And it would be, by far, the fastest way to do it. SPUtility.js would be a good candidate for a library that brings all the functions you need: https://github.com/kitmenke/sputility


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

This doesn't seem logically possible. Think about it. ExecuteOrDelayUntilScriptLoaded does exactly what it says on the tin: if the specified script has already been loaded your function will be executed "immediately" but if the script is still not loaded then your function will wait in a queue until such process completes. This means that you can't really ...


1

Even if you could somehow reliably grab the current user's home network, this approach will not work. The embed is going to look for a group on the specified network with the specified ID, and that group does not exist on those other networks. You need to specify the network that hosts the group in your embed code. If the external users are part of the ...


1

How about using window.dynamicTable anywhere you want, that sticks stuff in the global scope It is of course better to create your own scope for variables/functions. window.myScope = window.myScope || {} or to make it MDS save Type.registerNamespace('myScope');


1

You break everything with with this script-tag: <script language="javascript" src="/_layouts/15/sp.js"></script> Remove this one and your script should work just fine


0

Maureen, I think the reason that this is allowed in the first place is that the element <weatherform> does not have any meaning either to SP designer nor to the HTML parser. Hence, you are able to add the tag without nesting forms; the element's type is undefined, do you cannot . What you may want to do is give your select input (I'm making an ...


0

Check the wiki here for how to do it using a Content Editor web part: https://github.com/OfficeDev/PnP-JS-Core/wiki/Install-and-Use


0

UPDATE: This did NOT work since the FedAuth cookie is HttpOnly protected and can not be accessed in javscript. So we dumped the entire idea and created a proxy webservice directly hosted in Sharepoint. Looks like this is working, but it is ugly... This is how we solved it (not, see above): We looked at the source code of the Sharepoint STS, especially at ...


0

From the downloaded files you add to your project pnp.js, pnp-provisioning.js and jQuery. By doing this you can use the $pnp.sp object.


0

try this <button class="btn btn-default" type="button" onclick="history.go(-1);" id="btBack">Back</button>


4

Fortunately I lately also needed a back button, so I can give you a working solution for it: Just simply add this Code to a Script Editor Web Part or Content Editor Web Part on the Site where u want it. <input type="button" value="back" onclick="window.history.back()" style="color: white; background-color:rgb(196, 196, 196); font: 15px arial, sans-serif; ...


0

Follow below mentioned steps : Write your code in a text file. upload it to any library. Now open your webpart page in edit mode Add Content Editor wbpart go to webpart setting. set path for the txt file uploaded in library click ok and you are all set


0

Replace following block from your code CmalQuery = "<View><Query><Where><Or>"; while (e.moveNext()) { fieldName = e.get_current(); CmalQuery += "<Contains><FieldRef Name='"+fieldName+"' /><Value Type='Text'>" + txtValue + "</Value></Contains>"; console.log(...


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.


0

You can try below code Approach 1 : $(document).ready(function() { var userID = <<input your user ID >> var siteUrl = <<input site url>> 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/...


0

100 is a server imposed limit to support paging. To bypass you should use $top in your query. Recommended approach is to keep the 100 limit and page through the result using _next return value.


0

Just replace the element '#name' for whatever your "hello, userName" is. function getCurrentUser() { console.log('Made it'); var ctx = SP.ClientContext.get_current(); var web = ctx.get_web(); var currentUserObj = web.get_currentUser(); ctx.load(currentUserObj); ctx.executeQueryAsync( ...


0

Try with this endpoint url, https://<site url>/_vti_bin/ListData.svc/<List Name>/$count


2

You can also try this using CSOM: function GetChoiceValues() { var context = new SP.ClientContext.get_current(); var web = context.get_web(); this.taskList = web.get_lists().getByTitle("CMA"); this.fields= this.taskList.get_fields(); var deptChoiceField = context.castTo(this.taskList.get_fields().getByInternalNameOrTitle("Category"),SP.FieldChoice);...


5

Using rest API, just make a GET request to the following end-point: _api/web/lists/GetByTitle('List Name')/fields?$filter=EntityPropertyName eq 'Choice Field Name'" Example using jQuery $.ajax({ url: "host url"+"_api/web/lists/GetByTitle('List Name')/fields?$filter=EntityPropertyName eq 'Choice Field Name'", type: "GET", headers: {...


0

FYI, you can get rid of the hardcoded Field name And condense the code a bit (not checked for typos) var value = ctx.CurrentItem[ctx.CurrentFieldSchema.Name]; var html = "<span class='tooltip'><i class='fa fa-lg {0}' style='color:{1}'></i><span class='tooltiptext'>{2}</span></span>"; var data = { "Available" : ...


0

I found two issues in your code: The field name is "Case_x0020_Status" and not "Case Status" You have to add your functions to your namespace before you call them See the working code below: Type.registerNamespace('Lifeline') Lifeline.Templates = Lifeline.Templates || {} Lifeline.Functions = Lifeline.Functions || {} Lifeline.Functions.statusViewFormat =...


8

Check out this excellent article where the performance of both is tested: Deep Dive – REST and CSOM Comparison I tested a series of pretty common operations in both REST and CSOM: Creating Lists (10) Creating List Items (100 per List, for a total of 1000) Reading List Items by ID Querying for List Items (retrieving 50 per List) Deleting List ...


2

Nice question, "Which one is faster CSOM or JSOM for CRUD operation?". But the fact to determine which API to be used for performing a certain operation in SharePoint depends on various factors like type of application, operating system, what kind of operation is to be performed in which system and so on. Based on the MSDN reference, I would say, go with ...


1

Liz, I was having similar issue but I followed this link http://summit7systems.com/who-needs-a-data-view-web-part-sharepoint-rest-and-datatables-net and it worked perfectly. Following is my code (see if it's helpful) <script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js"></script> <link ...


2

That should do the trick .ms-formtable > tbody > tr:nth-child(x) > .ms-formbody { border-bottom: 1px solid #ccc; } If you want to have a line below the 1st question then replace x with 2. If you want to have a line below the 2nd question then replace x with 4 And so on..


1

You have to explicitly request for a JSON response (if the default response is XML) You need to give the server the RequestDigest (unique token) to prove you are who you are headers: { "accept": "application/json;odata=verbose", "X-RequestDigest": $("#__REQUESTDIGEST").val() }


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 ...


1

Sometime summer 2013 Microsoft added checks which made the use of a SCRIPT tag inside Calculated Columns impossible. So you have to rewrite it to: &"<img src='/_layouts/images/blank.gif' onload=""{" &"function myfun(){" &" return new Date().toString();" &"}" &" this.parentNode.innerHTML= myfun() ;" &"}"">" ...


1

You can Add Javascript file using Content editor or Script editor on the list view Page. So now only function call needs to be made on image load functionality, which should work smoothly. Kindly try to separate JS from the HTML content, this should work for you.


0

You can use JavaScript method: SP.UI.ModalDialog.showmodalDialog(options) Check MSDN for syntax and example.


1

You don't need to do any user checking yourself (if you have the Admins in a SharePoint Group) Do it the other way around. Hide webparts by default Make them visible for Admins, code in a CEWP with a Target Audience so it only executes for the Admin-Group This will also not flash/then hide contents


0

Please try below code: var ctx; SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady); function sharePointReady () { ctx = new SP.ClientContext.get_current(); var siteColl = ctx.get_site(); var rootWeb = siteColl.get_rootWeb(); this.props = rootWeb.get_allProperties(); ...


0

Change your SP.SOD.registerSod("sp.js", "\_layouts\SP.js"); to SP.SOD.registerSod("sp.js", "/_layouts/sp.js");. You need to use forward slashes instead of backslashes. Also, try using SP.SOD.executeFunc("sp.js", "SP.ClientContext", myfunction); instead of ExecuteOrDelayUntilScriptLoaded(myfunction, "sp.js");.


1

add a $select=myfield1,myfield2,etc onto your REST url. Note that once you add the $select parameter, only the fields you explicitly select will be returned. Without a $select parameter, all built-in fields are returned. See official doc on MSDN


0

Rather than CAML, why not use the search API. For example, if you use a content type for the CV, you could fire a second query from your display template using the search REST API to find the content ContentType=CV.



Top 50 recent answers are included