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

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

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


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


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

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

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

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

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

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


2

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


1

Where is the list located? Is it inside the same app web or the host web? If it is app web, then follow this article. If it is the host web, then you need to enable permissions in the app permissions to read list. Then access the host web voa javascript. All need to be done with JS Async calls.


1

I build something similar. I just checked if the current url contains the path of my navigation element. In your case the URLs would cause that multiple links are marked as active. But with a ordered set of URLs you can avoid this. // URLs ordered by length to ensure correct results var orderesNodes = []; orderesNodes[0] = ...


1

There are a couple of places that you need to change this on, You have done central admin but you also need to do web application web.config: search for httpRuntime and update to this: <httpRuntime executionTimeout="999999" maxRequestLength="5120" requestValidationMode="2.0" /> above allows only 5mb max, to increase the number: function: mb * ...


1

Regarding grouping in SharePoint REST, according to Use OData query operations in SharePoint REST requests, Grouping is not supported. One of the solution, is to apply grouping for the JSON results returned from REST endpoint. Example Suppose the following function for getting list items via SharePoint REST API: function getListItems(url, listname, ...


1

Basically what you are looking for is the Deferred loading mechanism (javascript 'promises'). The code block below returns a so-called 'promise'. This allows you for chaining different methods (and is a bit more controllable than the previous answer given). I've applied this to all of my sharepoint apps to keep stuff organized as well (+ you can build some ...


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

As shortcut you can use sg like: SP.UI.ModalDialog.showModalDialog( { html : $( "<h1>asdf</h1>" ).get( 0 ) } ); NOTE: if you have more than one tag you need to wrap everything into an embracing one otherwise only the first is shown: $( "<div><h1>asdf</h1><p>jkl;</p></div>" ).get( 0 )


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

Yes, you can do it from JS. The code will be something like this: (function () { var workflowInstanceId = 'PUT-YOUR-GUID-HERE'; var context = SP.ClientContext.get_current(); var web = context.get_web(); var servicesManager = SP.WorkflowServices.WorkflowServicesManager.newObject(context, web); var instance = ...



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