Updating Multiline Text Field Properties in SharePoint Using PowerShell
Introduction
Managing multiline text fields in SharePoint can be tricky, especially when certain field properties are not visible or editable at the library/list level, even though they are available at the site level.
For example, at the site level, you can configure properties such as:
- Append Changes to Text
- Number of Lines
- Field Type: Plain Text, Rich Text, or Enhanced Rich Text
However, these settings may not appear at the library/list level, as shown below:
Site Level
Library Level
If you need to update these settings at the library/list level, the only way to achieve this is by using PowerShell.
Updating Multiline Text Field Properties with PnP PowerShell
Below is a sample PowerShell script that demonstrates how to update multiline text field properties using PnP PowerShell.
Sample Script
param (
[Parameter(Mandatory = $true)]
[string]$Url,
[Parameter(Mandatory = $true)]
[string]$ListName,
[Parameter(Mandatory = $true)]
[string]$FieldName,
[Parameter(Mandatory = $true)]
[ValidateSet("EnhancedRichText", "PlainText", "RichText")]
[string]$TextType = "EnhancedRichText",
[Parameter(Mandatory = $true)]
[ValidateSet("Yes", "No")]
[string]$AppendOnly = "Yes"
)
# Connect to SharePoint site
Connect-PnPOnline -Url $Url
# Map the TextType to corresponding RichTextMode and RichText values
switch ($TextType) {
"EnhancedRichText" {
$RichTextMode = "FullHtml"
$RichText = $true
}
"PlainText" {
$RichTextMode = "Compatible"
$RichText = $false
}
"RichText" {
$RichTextMode = "Compatible"
$RichText = $true
}
}
# Convert AppendOnly parameter to boolean
$AppendOnlyValue = if ($AppendOnly -eq "Yes") { $true } else { $false }
# Update field properties
Set-PnPField -List $ListName -Identity $FieldName -Values @{
AppendOnly = $AppendOnlyValue
RichTextMode = $RichTextMode
RichText = $RichText
NumLines = "6"
UnlimitedLengthInDocumentLibrary = $false
} -ErrorAction Stop
# Handle properties that cannot be updated directly
$Field = Get-PnPField -List $ListName -Identity $FieldName -ErrorAction Stop
$FieldSchemaXml = [xml]$Field.SchemaXml
if ($TextType -eq "EnhancedRichText" -or $TextType -eq "RichText") {
$FieldSchemaXml.Field.SetAttribute("RichTextMode", $RichTextMode)
$FieldSchemaXml.Field.SetAttribute("NumLines", "8")
}
Set-PnPField -List $ListName -Identity $FieldName -Values @{
SchemaXml = $FieldSchemaXml.OuterXml
} -ErrorAction Stop
Key Notes
Number of Lines:
The “Number of Lines” property does not seem to have any visible effect on the field.RichTextMode and NumLines:
These properties cannot be updated directly usingSet-PnPField
. Instead, you need to modify theSchemaXml
property.UnlimitedLengthInDocumentLibrary:
This property, also known as “Allow unlimited length in document libraries,” enables saving more than 255 characters in a field.Append Changes to Text:
When this setting is enabled, “View Entries” is displayed within the multiline text field as a link to the display form.
Conclusion
Using PowerShell, you can easily update multiline text field properties in SharePoint that are otherwise inaccessible at the library/list level. This script is particularly useful for administrators who need to configure fields programmatically across multiple lists or libraries.