Skip to content

Instantly share code, notes, and snippets.

View PatD's full-sized avatar

Patrick Doran PatD

View GitHub Profile
@PatD
PatD / SharePoint 2010 SP Services get list item counts in a collection
Created January 21, 2015 21:23
SharePoint 2010 - SP Services - get list item counts in a collection
// Assumes jQuery and SP Services
// Outputs all lists and their item count
// From @sympmarc http://sympmarc.com/2010/09/19/down-and-dirty-spservices-solution-to-solve-an-emergency-request/
$(document).ready(function() {
$().SPServices({
operation: "GetAllSubWebCollection",
async: true,
completefunc: function (xData, Status) {
$(xData.responseXML).find("Web").each(function() {
javascript:(function(){var fieldsTable=null;var tables=document.getElementsByTagName('table');for(var i=0;i<tables.length;i++){if(tables[i].innerHTML.toLowerCase().indexOf('fldedit.aspx')>-1||tables[i].innerHTML.toLowerCase().indexOf('managecontenttypefield.aspx')>-1){fieldsTable=tables[i];}}if(fieldsTable!=null){var th=fieldsTable.rows[0].insertCell(fieldsTable.rows[0].cells.length);th.innerHTML='Internal name';for(var i=1;i<fieldsTable.rows.length;i++){var link=fieldsTable.rows[i].cells[0].getElementsByTagName('a')[0].href;link=link.split('?')[1];link=link.split('&');for(var j=0;j<link.length;j++){if(link[j].indexOf('Field=')==0){link=link[j].split('=')[1];break;}};var td=fieldsTable.rows[i].insertCell(fieldsTable.rows[i].cells.length);td.innerHTML=unescape(link);}}})();
javascript:(function(w){if("undefined"===typeof jQuery){var jq=document.createElement("script");jq.type="text/javascript";jq.src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js";document.getElementsByTagName("head")[0].appendChild(jq)}var requestHeaders={Accept:"application/json;odata=verbose","X-RequestDigest":jQuery("#__REQUESTDIGEST").val()};var iList=w.prompt("Please enter the list name","Tasks");var a=jQuery.ajax({url:_spPageContextInfo.webAbsoluteUrl+"/_api/lists/getbytitle('"+iList+"')?$select=Fields&$expand=Fields",type:"POST",contentType:"application/json;odata=verbose",headers:requestHeaders,success:function(data){console.log(data);var fields=data.d.Fields.results,f={};for(i=0;i<fields.length;i++){console.log("Title: "+fields[i].Title+" | "+"Internal Name: "+fields[i].InternalName+" | "+"Type: "+fields[i].TypeAsString+" | "+"GUID: "+fields[i].Id+" ");var _f={Title:fields[i].Title,InternalName:fields[i].InternalName,Type:fields[i].Type,GUID:fields[i].GUID,meta:fields[i]};console.log(_f);
javascript:(function (w) { w.location.href = ('undefined' !== typeof _spPageContextInfo ? _spPageContextInfo.webAbsoluteUrl : w.location.origin + L_Menu_BaseUrl) + "?contents=1"; })(window)
javascript:(function (w) { w.location.href = ('undefined' !== typeof _spPageContextInfo ? _spPageContextInfo.webAbsoluteUrl : w.location.origin + L_Menu_BaseUrl) + "/_layouts/closeConnection.aspx?loginasanotheruser=true";})(window)
@PatD
PatD / createListItem.js
Created February 27, 2017 02:38
SharePoint Create List Item with JavaScript. Shows response w/SP.UI.Notify
// Function that creats a list item.
// Expects a title and category to be passed to it.
function createListItem(titleText,categoryText) {
// Where are we in SharePoint?
var _clientContext = SP.ClientContext.get_current();
// SharePoint List name
var _talkList = _clientContext.get_web().get_lists().getByTitle('list name');
@PatD
PatD / SharePoint 2016 - Make Ribbon look like 2013
Created September 19, 2018 14:51
Makes an on-premise SharePoint 2016 ribbon look/work like the 2013 Ribbon.
<style>
/* SP2016 Ribbon adjustments */
/* Puts babysuiteBar in the corner */
#suiteBarDelta {position: absolute;top:0;right:0;max-width:300px;}
/* Hides Waffle button */
#suiteBarDelta .o365cs-nav-leftAlign {display:none;}
/* Hides About Me in dropdown */