Skip to content

Instantly share code, notes, and snippets.

var TemplatePicker = TemplatePicker || {};
TemplatePicker.Config = {
client_id: <INSERT CLIENT ID GUID>,
redirect_base_uri: <INSERT THE URL OF THE APP>
};
@beckettkev
beckettkev / Loading a SPModal.js
Created March 18, 2016 15:59
Loading a SPModal window in SP passing the parent window location
function getWindowLocation() {
var caller = '';
['protocol','//','hostname','pathname'].forEach(function(item, i) {
caller += item === '//' ? item : window.location[item];
});
return caller;
}
@beckettkev
beckettkev / SharePoint Search Navigation Nodes.js
Created March 18, 2016 14:51
How to get the SharePoint Search Navigation Nodes via the REST API
/*
Replace <TENANT> with your tenant sub domain (e.g. MyCompany) and <SITE> with the site or site collection (e.g. sites/news)
*/
https://<TENANT>.sharepoint.com/<SITE>/_api/web/Navigation/GetNodeById(1040)/Children
@beckettkev
beckettkev / Get Location of Parent.js
Last active March 18, 2016 16:50
How to get Parent frames location from within a page called using the SP.UI.Dialog
function getParentWindowLocation() {
document.domain = 'sharepoint.com';
var caller = '';
['protocol','//','hostname','pathname'].forEach(function(item, i) {
caller += item === '//' ? item : window.parent.location[item];
});
return caller;
(function($) {
//...insert code as required.
})(jQuery);
@beckettkev
beckettkev / TermSetHelper.js
Created March 11, 2016 14:03
Get all TermSets for a TermStore in SharePoint Online
jQuery.getScript(getBaseUrl() + '/_layouts/15/sp.taxonomy.js', function () {
var context = new SP.ClientContext.get_current();
var session = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
var termStore = session.getDefaultSiteCollectionTermStore();
var groups = termStore.get_groups();
var termSets = [];
context.load(groups);
@beckettkev
beckettkev / Get all x Property for a users with SharePoint Search.js
Last active March 11, 2016 14:45
Get all x Property for Users in SharePoint
var userProfileDataCollection;
SearchPropertyFetcher = function(options) {
var id, skip;
var properties = options.properties || ['PreferredName','WorkEmail'];
var base = options.url || window.location.protocol + '//' + window.location.host;
function wash(results) {
var people = [];
var pairs;
@beckettkev
beckettkev / AppTiles.xml
Created March 10, 2016 12:26
App Tiles API Rest Call - Get the Redirect URL of a Provider Hosted App
<entry>
<id>https://arup.sharepoint.com/_api/SP.AppTile49d8c71a-25bd-4325-ac19-71e8411be2ae</id>
<category term="SP.AppTile" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<link rel="edit" href="SP.AppTile49d8c71a-25bd-4325-dc19-31e8412ae5ae"/>
<title/>
<updated>2016-03-10T12:22:48Z</updated>
<author>
<name/>
</author>
<content type="application/xml">
@beckettkev
beckettkev / Get All Job Titles - SharePoint 2013.js
Last active March 8, 2016 14:02
Quick helper script to get all job titles for users on a given site. This is not possible from the User Profile or Search (due to the base properties it returns in search results).
/*
The following JS example gets all Job Titles from the Site User Table and stores them in an array (collection)
Due to it's dependancies on map, filter, sort etc.. you will need to add the relevant shim to get this to work on IE9<
*/
var collection, id;
var siteBaseUrl = '<SHAREPOINT BASE URL GOES HERE>';
function processPayLoad(data) {
return data.value.map(function(item, i) {
getUserById: function (id) {
var self = this;
return new Promise( function( resolve, reject ){
if ( id ){
var context = new SP.ClientContext.get_current();
var userInfoList = context.get_web().get_siteUserInfoList();
var query = new SP.CamlQuery();