Tag Info

Hot answers tagged

4

I normally follow as below SP.SOD.executeFunc('sp.js', 'SP.ClientContext', readyFunction); function readyFunction() { getCurrUser(); evalGroups(); getDeptMgrs(); getItemOwner(); } Its more readable!


3

Ribbon should already contain this information. You can get the view name like this: SP.Ribbon.PageManager.get_instance().getPageComponentById('WebPartWPQ2')._data.ViewName _data property contains all kinds of fun stuff.


3

scenario: when you enter form editing and has some user of this picker people, this is the "oldHtml"? (I'm finding this a bad practice) try using this code: var getIDPeoplePicker=$("div[Title='Column Name of the people picker here']").id; var ppobject = SPClientPeoplePicker.SPClientPeoplePickerDict[getIDPeoplePicker]; var usersobject = ...


3

In this approach it is determined whether User belongs to specific Group and if so, then he/she is getting redirected to another page: function isUserMemberOfGroup(userId, groupId, success,error) { var ctx = SP.ClientContext.get_current(); var allGroups = ctx.get_web().get_siteGroups(); var group = allGroups.getById(groupId); ...


3

I'm assuming you're on a standard SharePoint page -- if so, you can use the _spPageContextInfo object's userId and userLoginName properties. They come along for the ride when the page is rendered. From my browser dev tools: >_spPageContextInfo.userId 1337 >_spPageContextInfo.userLoginName "somebody@somecompany.onmicrosoft.com" If you're dealing ...


3

The error: The user does not exist or is not unique most probably occurs since user could not be found. The list of methods that could be utilized for removing a user from group: SP.UserCollection.remove SP.UserCollection.removeById SP.UserCollection.removeByLoginName The following examples demonstrate how to remove User from Group using ...


3

The folder isn't in SharePoint Designer (or more specifically, isn't inside the web/site collection) instead it is in 15 hive which is physically located here (and is shared with all the webs/site collections): C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15


2

Improving the code suggested by @wjervis, you can change the header of ajax request to: headers: {          'accept': 'application/json;odata=verbose'      } This way it will return a Json response, that I think it is more easy to handle. You can get the length of the response by doing: data.d.results.length Additionally, you can put one more "expand" ...


2

You could utilize Regional Settings REST endpoint: /_api/web/RegionalSettings/TimeZone to retrieve SharePoint Time Zone settings and then get time for that time zone: function getSPCurrentTime(webUrl) { return $.ajax({ url: webUrl + "/_api/web/RegionalSettings/TimeZone", method: "GET", headers: { "Accept": "application/json; ...


2

There is a slight difference on how ExecuteOrDelayUntilScriptLoaded works depending on what page it is being executed on. Sometimes SP.js is available and other times it is not. When it's not availble, the call to ExecuteOrDelayUntilScriptLoaded will fail as SP.js is not loaded. View my answer to a similar question here for more on this.


2

With "_spPageContextInfo" you can get all properties of app. If you want only url of APP : var AppWebUrl = _spPageContextInfo.webAbsoluteUrl; this code is the same of appweburl in query parameter. But to get SPHostUrl try the method getQueryStringParameter(valueString) var hostUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl")); ...


2

function manageQueryStringParameter(paramToRetrieve) { var params = document.URL.split("?")[1].split("&"); var strParams = ""; for (var i = 0; i < params.length; i = i + 1) { var singleParam = params[i].split("="); if (singleParam[0] == paramToRetrieve) { return singleParam[1]; } } } var ...


2

After trying out different options available online, I was able to achieve it by JavaScript <!--SPM:<SharePoint:ScriptLink ID="ConfigurationScriptLink" Name="~sitecollection/SiteAssets/js/Configurations.js" runat="server"/>--> CSS <!--SPM:<SharePoint:CssRegistration ID="CSSCustom" Name="&lt;% ...


2

The following example demonstrates how to read Json file and parse it (the data from your JSFiddle has been saved into file): $.getJSON("/SiteAssets/Announcements.data", function(data) { var rowsData = data.NewDataSet.GetListItems.listitems['rs:data']['z:row']; var content = renderRows(rowsData); $('#listview').append(content); }); function ...


2

Try this $(document).ready(function(){ $('#ctl00_m_g_de548742_27f6_4e71_b3ec_2d9a1ecca117_ff151_ctl00_DropDownChoice').on('change', function(){ var accountType = this.value; if(accountType == 'Military') { $('.milShow').show(); $('.ctrShow').hide(); $('.civShow').hide(); } ...


1

SPWeb has RootFolder which internally has WelcomePage property. You can use that to get this information var clientContext = new SP.ClientContext.get_current(); var spWeb = clientContext.get_web(); var rootFolder = spWeb.get_rootFolder(); clientContext.load(rootFolder, 'WelcomePage'); clientContext.executeQueryAsync(Function.createDelegate(this, ...


1

If you want to move your content away from the quick launch, try this: <style type="text/css"> #contentBox { margin-left: 250px; /* default is 220px, so increase to whatever value you like */ } </style>


1

You can use a GUID or the display name for the listName parameter in SPServices. Make sure you use the curly brackets in the GUID. var lookupFieldInternalName = "LookupOne"; $().SPServices({ operation: "GetList", listName: "{C1AA0A1F-8177-4D64-AC3F-FDCFB31EFCA5}", completefunc: function(xData, Status) { console.log(xData.responseText); ...


1

In SharePoint 2013 prefer SP.SOD.executeFunc(key, functionName, fn) Method instead of SP.SOD.executeOrDelayUntilScriptLoaded(func, depScriptFileName) Method to ensure that sp.js library is loaded before the specified callback function runs. Solution Replace: ExecuteOrDelayUntilScriptLoaded(PopulateDropDown, "sp.js"); with SP.SOD.executeFunc('sp.js', ...


1

ExecuteOrDelayUntilScriptLoaded Method You can try this: jQuery(document).ready(function() { ExecuteOrDelayUntilScriptLoaded(myfunction, "sp.js"); }); myfunction = function(){ /*Do something here.*/ }; Or try following the answer found here: ExecuteOrDelayUntilScriptLoaded(function () { alertThis("Hello World") }, "core.js"); function ...


1

I'm not sure what you mean with freeze, but I can't see where you call or close the "working on it". I made simple example with dummy code, maybe it will help you. Because I have never seen that async calls have locked the UI etc, so you could try this approach: SP.UI.ModalDialog.showWaitScreenWithNoClose("title", "message", 400, 400); var ...


1

We have used Spin.js in several such scenarios. Usage Define a <div> in the HTML markup <div id="userTableSpinner"></div> Then in Javascript code find the div and start spinner and finally stop it once all processing is done: var userTableSpinner; function someProcessStartsHere() { if (userTableSpinner == null) { userTableSpinner ...


1

I couldn't find any documentation regarding any explanation regarding this in SharePoint 2013. But practically my observation is that now(in SP2013) irrespective of number of items, every lookup field is rendered as a Drop-down/Select control.


1

I could be mistaken, but I think your problem is makeProperUrl function. Based on your comments in your question I'm going to assume that the function returns the app web url from query string, and in most cases this will not end with a slash, so then your query would try to access .../MyPrettyLittleAppUrl_api/web... To fix this simply add a forward slash ...


1

I figured out the error was (as the error states) a value being passed into the setStart and setEnd functions of the Range "class" that was out of range. (Not the RTE.Range "class") The signature takes two parameters, a DOM object and an integer value. In my case the value 2 was over the bounds of range. Without spending much time, I wasn't able to figure ...


1

This is happening because SP.UI.Dialog.js file is not loaded. Modify your code as below <script type="text/javascript"> function openDialog( pUrl ) { var options = { url: pUrl, width: 650, height:600, title: "MyTitle" }; SP.SOD.execute('sp.ui.dialog.js', ...


1

The syntax you use when filtering fields to return inside of the load method depends on wether you're dealing with a collection or an individual object. You're encountering an error because you've specified the syntax for dealing with a collection: clientContext.load(collOfItems, 'Include(Field1,Field2)'); What you need is the alternate syntax for ...


1

This can be achieved by creating a CustomAction. The CustomAction will create an ECB menu. On click of the menu a page (usually a layouts page) will be called. The CustomAction will pass the current list and list item ID to the page. The page will contain code to read the passed information and send email with attachment. An ECB menu example: <?xml ...


1

I came across this scenario a little while back. If i'm not mistaken, I think you will need to 'create' an App Web as a proxy for your REST calls. You also need to alter the AppManifest.xml to add the following entry: <Internal AllowedRemoteHostUrl="~remoteAppUrl"/> in place of <RemoteWebApplication ClientId="*" /> However, this will also ...


1

This is easily done by creating a custom list with a 1 number column to store the value. Create an element in this list with 0 as value. Then create a script that gets and increments this value through the REST API for lists, and the saves the new value in the list. Add this script in a Script Editor Web Part.



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