Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Kent thechriskent

View GitHub Profile
@thechriskent
thechriskent / Title Column.json
Last active Nov 12, 2020
Quick List Formatting sample illustrating recreating the Title Column
View Title Column.json
{
"elmType": "div",
"children": [
{
"elmType": "button",
"customRowAction": {
"action": "defaultClick"
},
"attributes": {
"class": "ms-fontColor-neutralPrimary ms-borderColor-white ms-borderColor-neutralPrimary--hover"
View ConvertBannerImageUrlToBase64.ps1
# Connect to your site
# (this example assumes an entry in Windows Credential Manager,
# but you can pass credentials however you need here)
Connect-PnPOnline https://yourtenant.sharepoint.com/sites/yoursite
$connection = Get-PnPConnection
# Setup a Web Client using credentials pulled from the connection
$client = New-Object System.Net.WebClient
$client.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($connection.PSCredential.UserName, $connection.PSCredential.Password)
$client.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f")
View UnicornEmojis.json
{
"elmType": "div",
"children": [
{
"elmType": "span",
"txtContent": "🦄",
"style": {
"display": "=if([$Rating] >= 1, 'inherit','none'"
}
},
View Unicorns.json
{
"elmType": "div",
"style": {
"fill": "#ffaaaa"
},
"children": [
{
"elmType": "svg",
"style": {
"width": "18px",
View Document Library Link.json
@thechriskent
thechriskent / SharePoint Embed Domains.ps1
Created Nov 11, 2019
Demonstrates adding a domain to the list of allowed domains across multiple SharePoint sites (useful for the Embed webpart)
View SharePoint Embed Domains.ps1
$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
View Author Fix for page modernization
#Script to fix the user mapping issues from page modernization
$SiteUrls = @(
"SGA"
)
$shouldFix = $true
try {
$checkedoutPages = @()
foreach($SiteUrl in $SiteUrls) {
View LogItemUsage.js
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);
View iconFormat.json
{
"$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
"elmType": "div",
"children": [
{
"elmType": "span",
"attributes": {
"iconName": "Balloons"
},
"style": {
View svgIconFormat.json
{
"$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
"elmType": "div",
"children": [
{
"elmType": "svg",
"style": {
"padding-right": "6px",
"width": "13px",
"height": "13px",