Skip to content

Instantly share code, notes, and snippets.

@thechriskent
thechriskent / columnFormattingSchema.json
Last active September 24, 2019 13:20
A Verbose Schema for SharePoint Column Formatting (Proposed)
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "CustomtFormatter JSON",
"description": "CustomFormatter renderer for SharePoint lists",
"definitions": {
"customAction": {
"type": "object",
"additionalProperties": false,
"title": "Action object",
"description": "Action object for a custom action button",
@thechriskent
thechriskent / ColorColumns.json
Last active December 11, 2017 23:44
Quick sample of applying customized colors
{
"$schema": "https://gist.githubusercontent.com/thechriskent/2e09be14a4b491cfae256220cfca6310/raw/eb9f675bf523208eb840c462d4f716fa92ce14c2/columnFormattingSchema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"color": {
"operator": "?",
"operands": [
{
"operator": "==",
{
"$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
"elmType": "div",
"children": [
{
"elmType": "svg",
"style": {
"padding-right": "6px",
"width": "13px",
"height": "13px",
{
"$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
"elmType": "div",
"children": [
{
"elmType": "span",
"attributes": {
"iconName": "Balloons"
},
"style": {
function logItemUsage(itemId, listName) {
SP.SOD.executeOrDelayUntilScriptLoaded(function() {
var stuff = {
ctx: SP.ClientContext.get_current()
};
stuff.user = stuff.ctx.get_web().get_currentUser();
stuff.ctx.load(stuff.user);
stuff.scope = "{00000000-0000-0000-0000-000000000000}";
stuff.site = stuff.ctx.get_site();
stuff.ctx.load(stuff.site);
#Script to fix the user mapping issues from page modernization
$SiteUrls = @(
"SGA"
)
$shouldFix = $true
try {
$checkedoutPages = @()
foreach($SiteUrl in $SiteUrls) {
@thechriskent
thechriskent / SharePoint Embed Domains.ps1
Created November 11, 2019 21:02
Demonstrates adding a domain to the list of allowed domains across multiple SharePoint sites (useful for the Embed webpart)
$SiteUrls = @("HR","Accounting","IT")
foreach($SiteUrl in $SiteUrls) {
Write-Host -ForegroundColor Cyan "Applying to $SiteUrl..."
$FullSiteUrl = "https://superspecial.sharepoint.com/sites/$SiteUrl"
Connect-PnPOnline $FullSiteUrl -ErrorAction Stop
{
"elmType": "div",
"style": {
"fill": "#ffaaaa"
},
"children": [
{
"elmType": "svg",
"style": {
"width": "18px",
{
"elmType": "div",
"children": [
{
"elmType": "span",
"txtContent": "🦄",
"style": {
"display": "=if([$Rating] >= 1, 'inherit','none'"
}
},