Skip to content

Instantly share code, notes, and snippets.

@OlafD
OlafD / ModifySurveyOverview.html
Created May 15, 2019 12:49
Hide Number of Responses in a survey overview.
<script type="text/javascript">
$( document ).ready(function() {
$("#overview04").parent().hide();
});
</script>
@OlafD
OlafD / MakeTitleVisibleForFolders.ps1
Created May 9, 2019 06:39
Make the title field visible for editing in the Folder content type in a library in SharePoint.
# get the content type from the library
$ct = Get-PnPContentType -Identity "Folder" -List "Documents"
# get the fieldlinks collection from the content type
$fieldLinks = $ct.FieldLinks
(Get-PnPContext).Load($fieldLinks)
Invoke-PnPQuery
# get the title field from the site columns
$titleField = Get-PnPField -Identity "Title"
@OlafD
OlafD / AddFieldToFolderCT.ps1
Created May 8, 2019 06:49
Add a field to the (sealed) content type "Folder" in a library.
# 1) unseal the content type for folders in the library
$ct = Get-PnPContentType -Identity "Folder" -List "Documents"
$ct.Sealed = $false
$ct.Update($false) # using $true in this case will throw an execption
Invoke-PnPQuery
# 2) add the description field (must already exist) to the Folder content type
@OlafD
OlafD / HideFieldInEditForm.ps1
Created April 25, 2019 17:29
For a field in a list set the property, to make it hidden in the edit form.
$field = Get-PnPField -List "My List" -Identity "Target Date"
$field.SetShowInEditForm($false)
$field.Update()
Invoke-PnPQuery
@OlafD
OlafD / DocumentTextFromOCR.xml
Created April 18, 2019 08:39
Very simple proof of concept for indexing pdf files iin SharePoint online that are results of scanned content and contain mainly images. This sample uses IronOcr to get the text content of the file.
<Field
ID="{1012e6c5-2eb5-44cf-9f73-1ed8a584d38b}"
Name="DocumentTextFromOCR"
DisplayName="Document Text from OCR"
Description=""
StaticName="DocumentTextFromOCR"
Group="Demo"
Type="Note"
NumLines="10"
UnlimitedLengthInDocumentLibrary="TRUE"
@OlafD
OlafD / LoadFAQ.html
Created March 27, 2019 11:18
Html and JavaScript to embed on a SharePoint wiki page with a Content Editor Webpart. This file is part of the FAQ sample solution.
<style>
.accordion {
background-color: #eee;
color: #444;
cursor: pointer;
padding: 18px;
width: 100%;
text-align: left;
@OlafD
OlafD / CreateFAQList.ps1
Created March 27, 2019 11:16
Script to create the FAQ sample structure.
param (
[Parameter(Mandatory=$true)]
$Url,
$Cred,
[switch]$UseWebLogin
)
if ($UseWebLogin.ToBool() -eq $false)
{
if ($Cred -eq $null)
@OlafD
OlafD / PowerShellPnP-StartScript.ps1
Created March 27, 2019 07:48
Simple starter für a PowerShell script, when needed to connect to the SharePoint Online site. Can work with credentials or web login.
param (
[Parameter(Mandatory=$true)]
$Url,
$Cred,
[switch]$UseWebLogin
)
if ($UseWebLogin.ToBool() -eq $false)
{
if ($Cred -eq $null)
@OlafD
OlafD / CreateDeploymentPackage.ps1
Last active March 26, 2019 11:20
Create a zip-file for the deployment of a WebJob in an Azure Web Application. In the zip-file xml- and pdb-files are excluded.
param (
$Path,
$DestinationPath,
$ZipFile
)
Write-Host "Path: $Path"
Write-Host "DestinationPath: $DestinationPath"
Write-Host "ZipFile: $ZipFile"
@OlafD
OlafD / MoveFieldBehind.ps1
Created March 24, 2019 10:57
Move the field to the position behind another field in a content type. This script makes use of two other script files stored as gists.
function MoveFieldBehind
{
param (
[string]$ContentTypeName,
[string]$FieldToMove,
[string]$AnchorField
)
Write-Host "Put field $FieldToMove behind $AnchorField in Content Type $ContentTypeName"