Tag Info

Hot answers tagged

4

You could perform this via CSOM/REST API. Use SP.Web.getFileByServerRelativeUrl Method to request File object and specify SP.File.listItemAllFields property to load list item field values for the list item corresponding to the file: var ctx = SP.ClientContext.get_current(); var file = ctx.get_web().getFileByServerRelativeUrl(url); //get file ...


4

What about using the Add method: If for example using SiteCollectionDocuments in a Site Collection 'url' : _spPageContextInfo.siteAbsoluteUrl + "/_api/Web/Folders/add('SiteCollectionDocuments/newfolder')" This shouldn't require the data payload 'postData'. See more here: ...


4

Sure you can. It's JS code after all and you could either use global variable to store your information or the provided ctx object. Here' a example for both possibilities: ControlTemplate: <!--#_ window.ThisIsGlobal = "this works !"; ctx.MyVar = "THIS WORKS !"; _#--> ItemTemplate: <!--#_ ...


3

this function set field limit characters: function setFieldLimitCharacters( field, limit ) { field.unbind( 'keyup change input paste' ).bind( 'keyup change input paste',function(e){ if( $( this ).val().length > limit ) { $( this ).val( $( this ).val().substring( 0, limit ) ); } }); } usage: ...


3

You can add this script: <script type="text/javascript" language="javascript"> function PreSaveAction() { var elm = document.getElementById("idAttachmentsTable"); if (elm == null || elm.rows.length == 0) { document.getElementById("idAttachmentsRow").style.display='none'; alert("Please attach Documents"); return ...


3

Update 2 Just using <script type="text/javascript"> document.getElementById('lblSomething').innerHTML = "Here is REALLY something!"; </script> without error handling will most likely cause runtime issues because if the code runs before the label is rendered it will throw a global JS exception causing the issues I already mentioned. So, ...


3

Make sure the correct ServerRelativeUrl has been provided, the following formats could be specified: Server-relative URL: /<web url>/<list url>/<folder url> Site-relative URL: <list url>/<folder url> For example, to create a folder named Orders in a Documents library in a sub site Projects, you could specify: ...


2

I believe the simplest and recommended way to achieve this is using either the SharePoint JavaScript Object Model or AJAX. Neither will cause the page to become unresponsive and both should be fast, even with several thousand items. If you are performing just one query, the SharePoint JavaScript Object Model is your best option. The following MSDN article ...


2

It depends whether User/Lookup field value is multiple or not, the following formats are used when specifying field value via SharePoint REST: Single User/Lookup value format: FieldName: LookupIdVal Mutiple User/Lookup value format: FieldName: {"results": [LookupIdVal1,LookupIdVal2] } How to set multiple lookup/user field value via SharePoint REST API ...


2

I think you'd need to do it in 2 calls. First, you'd have to query your list with a GetListItems call with CAML query like: <ViewFields> <FieldRef Name='ID' /> </ViewFields> <Where> <Eq> <FieldRef Name='LinkFilename' /> <Value Type='Computed'>file.txt</Value> ...


2

How to delete SP.Group in SharePoint 2013 via JSOM Use SP.GroupCollection.remove, SP.GroupCollection.removeById or SP.GroupCollection.removeByLoginName methods to remove Group from site. Example var context = SP.ClientContext.get_current(); var groups = context.get_web().get_siteGroups(); groups.removeById(groupId); context.executeQueryAsync( ...


2

Convert absolute URL into server-relative URL and use SP.Web.getFileByServerRelativeUrl Method to return file object located at the specified server-relative URL as demonstrated below: function getFileProperties(url,success,error) { var ctx = SP.ClientContext.get_current(); var relUrl = url.replace(_spPageContextInfo.siteAbsoluteUrl,''); //convert ...


2

In general you should avoid using executeQueryAsync inside of a loop -- for one you are generating an HTTP request with every call and second you just don't need to! The general pattern for something like this is to first load all of the objects you want, then executeQueryAsync, then work with the returned data. Here is an example that I've re-worked a ...


2

Pros A wide range of SharePoint functionality is exposed with the SOAP Web Services, much of which is not available in CSOM Allows anonymous access (assuming it is enabled for the underlying objects) Works cross-site and cross-domain, assuming that the authentication model you are using allows it Simpler syntax than the CSOM. Simply pass the required ...


2

It basically depends on your personal experience with the different technologies, there are many opinions out there with lots of pros and cons that may or may not be relevant to you. I personally very much dislike pure javascript CSOM because of all the context loading and SPServices was a good abstraction for that, but eversince I've used REST in SP2013 I ...


2

In order to retrieve File or Folder properties you could use the following associated List Item properties: FileRef - returns File/Folder relative Url FileLeafRef - returns File/Folder name Example function getListItems(listTitle,success,error) { var context = SP.ClientContext.get_current(); var list = ...


1

One possibility would be to add some javascript to your masterpage code's <head>. This code checks your current location and if the location has newform.aspx or editform.aspx in it, it'll hide the ribbon. <script type="text/javascript "src="http://mypath.com/Scripts/jquery.min.js</script> <script type="text/javascript"> $( document ...


1

One solution could be to use SharePoint REST and datatables.net. see link : http://summit7systems.com/who-needs-a-data-view-web-part-sharepoint-rest-and-datatables-net/


1

Like @cubanGuy answer.. try <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type=text/javascript> alert("yes"); </script > If that works, then you have a typo in your code. You could try to set "onchange" in the html code: HTML <select title="Option" id="iCard" ...


1

Have you tried: $("select [title='Option']".on('change', function(){ alert("yes"); });


1

You can try to place all the "behaviour" to javascript (should avoid inline handlers). Just add specific class to the trigger anchor and then in js write handler like something document.getElementsByClassName("myTrigger")[0].onclick = function(){ unhide('DivID'); return false; } Sharepoint page content editor is buggy in such things. I hope it will help ...


1

You can call javascript function in UrlAction: <UrlAction Url="javascript:YourMethod();" /> Make sure you have js reference in master page or you can add it using following lines in your element file: <CustomAction ScriptSrc="/scripts/myScript.js" Location="ScriptLink" Sequence="1"> </CustomAction>


1

In order to manage TaxonomyField properties there is no need to utilize SP.Taxonomy.TaxonomyField.getFieldValueAsTaxonomyFieldValue Method The following example demonstrates how to print TaxonomyField specific properties var ctx = SP.ClientContext.get_current(); var web = ctx.get_web(); var list = web.get_lists().getByTitle(listTitle); var field = ...


1

I use to call REST like this in my current project: var formDigest = $('#__REQUESTDIGEST').val(); $.ajax({ type: "POST", url: "your URL here", headers: { "X-RequestDigest": formDigest }, contentType: 'application/json; charset=utf-8', data: JSON.stringify({ "ParamName": "Param Value" }), datatype: 'json', }) .done(function (data) { ...


1

I have re-created this scenario, using the exact same versions of the plugins with a custom theme and custom background image, and everything is working fine. Perhaps you would want to take a broader look into your setup, as you may find outside variables, such as: all the pages and scripts, including the background images are publicly available double ...


1

In newform.aspx and editform.aspx of a SharePoint list item, a javascript function "PreSaveAction()" is called when the save button is clicked. By default, this function returns true, which enables SharePoint to Save/Update the item. You can override this function to provide your own validation. Within PreSaveAction(), you'll need to use AJAX to contact the ...


1

SP.UserProfiles.PersonProperties.userProfileProperties property returns an a dictionary of property name keys and their string values. In JavaScript you could use the following syntax to access value in a dictionary: myProperties.get_userProfileProperties().UserName or myProperties.get_userProfileProperties()['UserName'] Example var context = ...


1

Ok, here are my 2 cents CSS <style> /*bonus - show menu item icons*/ .ms-core-menu-link * {display: inline !important;} /*hide the first flyout*/ .js-callout-mainElement{visibility:hidden;} </style> Script <script> $(document).ready(function(){ //first click $('.ms-lstItmLinkAnchor').click(function(event){ ...


1

Get the list name using the variable ctx.ListTitle (reference: How to get List Name from JS Object Model - List Name from URL problem). Once you have the name of the current list, you can use the information from @tiago-duarte: How to find relative URL of a document library using CSOM Open up Chrome's Developer Tools and run "ctx" in the console. Inspect ...


1

You can find the Groups for an User using the Web Service GetGroupCollectionFromUser. SPServices can help you; but it's using jQuery. Same thing with SharepointPlus. You'll have to send a SOAP envelope (XML) to the Web Service. The body of your AJAX request will look like that: var body = "<soap:Envelope ...



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