Tag Info

Hot answers tagged

4

You can leverage SP 2013 Search API s for this if you have a search configured and continous crawling enabled and there is huge number of sub sites to be iterated otherwise. //Raw code not tested , just to give idea of what it will look like function getSite(){ var clientContext = new SP.ClientContext("<serverRelativeUrl>"); var contextSite = ...


4

There are two ways to call executeQueryAsync in JSOM: context.executeQueryAsync( Function.createDelegate(this, _onSucceed), Function.createDelegate(this, _onFail) ); and context.executeQueryAsync(_onSucceed, _onFail); The difference between the two is the former allows you to override what the value of the "this" variable will be inside the ...


3

Below example demonstrates how to customize List View in order to highlight list item rows. Assume there is a Tasks list and depending on status, rows have to be highlighted using the corresponding color. Template code: SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() { ...


3

You can use REST API to get the followed sites. Below is the REST endpoint GET http://<siteCollection>/<site>/_api/social.following/my/followedsitesuri you can get more details on below MSDN link https://msdn.microsoft.com/en-us/library/dn194080.aspx


3

Apart from the explanation given by Amal, the reason you see error is var collListItem; is defined in getAllFilesInFolders function and the onQuerySucceeded method doesn't have its information unless you use this.collListItem which is passed during Function.createDelegate(this, this.onQuerySucceeded). Else you should define var collListItem; globally in ...


2

As I mentioned in the comment, the approach which I would suggest is via a call to the list REST endpoint to retrieve the title. The endpoint to call is the following: tenant.sharepoint.com/_api/Lists(guid'4d46792d-0fd0-4850-aa29-4f3ea8310ac4')?$select=Title Here is an example item display template of how I achieved it: <html ...


2

The Load and ExecuteQuery combo (or ExecuteQueryAsync) is a necessary evil of any client-server programming. Your data resides in a remote location (your SharePoint server), so you cannot directly access it. In fact this is true even of any server-side programming, it is only less obvious. When you call Load, you are only preparing your query. As this ...


2

Garima's answer is fine but the problem is the PersonalUrl can be overwritten by the user. It remains as MySite Url when its pulled back in the code if its blank but if the user enters a value you get back that value instead of the MySite Url. A better function to use is get_userUrl(). So I'd change the above code to be: function getPersonalUrl() { var ...


2

You need to $select and $expand the AttachmentFiles property for your list items if you want to select many items from the list. _api/lists/getByTitle('MyList')/items?$select=AttachmentFiles,Title&$expand=AttachmentFiles Then you can get attachment info (if it exists) in the AttachmentFiles property of your list item which will be an array of ...


2

This is a known issue of IE7/8, see for example here or here: ECMA-262 r3 does not define any date formats. Passing string values to the Date constructor or Date.parse has implementation-dependent outcome. It is best avoided You could consider the following solutions: Use custom parseISO8601 function or Date.fromISO function to parse string to ...


2

Impersonation is not possible from Client Side JavaScript. Create a Read Only Group and provide permissions to all users to read the list items


2

You can validate if the JS files are loading using the browser tools. Open the page with your list instance on it and then open the browser tools (hit F12 key if you are windows machine). What you are looking for are the source files. Each browser is a little different (Chrome has a source tab, but FireFox has it under Debugger tab). You can also look ...


2

This should do the trick... OpenPopUpPage('mydialogurl', function() { window.location.href = "http://www.google.com" }) OpenPopUpPage has the following signature: SP.UI.ModalDialog.OpenPopUpPage(url, callback, width, height) The callback parameter takes any function you want called when the dialog is closed. I simply passed an anonymous function for ...


2

You need to find an alternative way to make your cross domain calls. As stated by the error, you cannot use the WebProxy if you're not inside an App. The App context is needed to tell the WebProxy that the URL being queried has been approved (it's part of the App manifest) Try creating a SharePoint Hosted app for the feature you are building and following ...


2

If you're dealing with a collection of items (example all of the items in a list, or all of the lists in a web), you need to use: clientContext.load(collOfItems, 'Include(Field1,Field2)'); For single items (like an individual site, list, or item) you need to use a comma seperated list of string arguments after the item to load, like: ...


2

This is how JavaScript client object model works. After loading, you need to execute clientContext.executeQueryAsync in order to get results back. However, if you don't like the asynchronous execution and want synchronous execution then you can use callbacks of deferreds. An example using JavaScript callbacks: $(document).ready(function () { //don't ...


2

The problem is with the use of OnDemand=true. If you set that property than you are asking Sharepoint to only load the scripts on demand i.e. when you explicitly call them. This techique is used to reduce the amount of scripts loaded at page load. When applied script can be requested to execute by using SP.SOD.execute or SP.SOD.executeFunc methods. .master ...


2

You can edit the master page HTML file and then add your CSS & JS references. The best practice is to take a copy of seattle.html (html master page) and then work on that. SharePoint online refer custom css and javascript in MasterPage (Site Assets)


2

If you just want to add a custom CSS and JS to your master page, then instead of creating a new master page, try the following and check if it works for your purpose. For Custom CSS : Use the Alternate CSS Url to set a custom CSS File. For referring a custom JS file follow this approach - ...


2

After a Save the page will get refreshed and the context is lost. The only option I can think of is to handle the button Save click event using jQuery. Other workaround Starting a Workflow on item create Handling Event Receiver ItemAdded Set SOURCE parameter so after item add it goes to a particular page. On that page add a window.load handler and execute ...


2

Values for a multi-select field should come back as a Collection type. The values for the Collection are available from the results property which is an array. Here's an example. My multi-select field is Color. var call = jQuery.ajax({ url: url, type: "GET", headers: { Accept: "application/json;odata=verbose" }, success: ...


2

You could use the response header from your REST request to figure out what date (and time) the server thinks it is. You can get at that information with something like: var req = $.getJSON("/_api/web/", function(data) { console.log(data) }) // doesn't matter, just make a request call... var serverDate = req.getResponseHeader("Date"); Then you'll just ...


2

You can use below code to find that information var clientContext = new SP.ClientContext(); //Get all groups in site var groupCollection = clientContext.get_web().get_siteGroups(); // Get the group by name group = groupCollection.getByName('GroupName'); //Get all SP Users in SP Group var userCollection = group.get_users(); ...


1

I suggest you use Fiddler (http://www.telerik.com/fiddler) to inspect the raw JSON being returned from the service call. Seeing what the raw data looks like should help you understand how it's represented in JavaScript.


1

I believe you are formatting the data using CSR. In that case you have full control over how the data will be rendered. Hence the easiest way to tackle this is, add the field to the View and then using CSS/JavaScript hide the fields you don't want to display. Else you should make another service call to get the data. Here is a sample you can try with ...


1

This is known issue with custom forms. Can you try replacing "<SharePoint:FormField" with <SharePoint:ClientPeoplePicker runat="server" ID="MyControlName" Required="true" ValidationEnabled="true" InitialHelpText="text" VisibleSuggestions="3" Rows="1" AllowMultipleEntities="true" CssClass="ms-long ms-spellcheck-true" /> you can also try the ...


1

If you aren't restricted from using the REST API, you could just use the $filter command to get the particular web URL you're looking for... this would result in one of the lightest weight network requests possible given the scenario. Try pasting this into your browser dev tools on your SharePoint site, it will log the Url into the console (you'll need ...


1

You can get the textbox with JavaScript and set it's value.. Use the below script to set the value of different types of fields.. Get or Set value for SharePoint field in NewForm, EditForm and DispForm (Get only in DispForm)


1

If the current user is part of the FARM ADMINISTRATORS group then the below code currentUser.get_loginName() will return Sharepoint\System. This is the expected behavior and you don't need to worry much. Try using a normal user account and you can see it returns the expected result. Alternatively you can also use currentUser.get_title()


1

Make sure the Page is published and approved. View the page source and make sure the element is present. Try to place the script inside window.onload event window.onload = function(){ var element = document.getElementById('myDiv'); alert(element); }



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