Skip to content

Commit a8509fe

Browse files
authored
Merge pull request #833 from reshmee011/multitiline
new sample script to update multiline text field
2 parents 56b946a + c15a98d commit a8509fe

File tree

4 files changed

+159
-0
lines changed

4 files changed

+159
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Updating Multiline Text Field Properties in SharePoint
2+
3+
## Summary
4+
5+
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.
6+
7+
For example, at the **site level**, you can configure properties such as:
8+
- **Append Changes to Text**
9+
- **Number of Lines**
10+
- **Field Type**: Plain Text, Rich Text, or Enhanced Rich Text
11+
12+
However, these settings may not appear at the **library/list level**
13+
14+
![Example Screenshot](assets/multilinetext_appendtoText_library_missing.png)
15+
16+
### Prerequisites
17+
18+
- The user account that runs the script must have access to the SharePoint Online site.
19+
20+
# [PnP PowerShell](#tab/pnpps)
21+
22+
```powershell
23+
param (
24+
[Parameter(Mandatory = $true)]
25+
[string]$Url,
26+
27+
[Parameter(Mandatory = $true)]
28+
[string]$ListName,
29+
30+
[Parameter(Mandatory = $true)]
31+
[string]$FieldName,
32+
33+
[Parameter(Mandatory = $true)]
34+
[ValidateSet("EnhancedRichText", "PlainText", "RichText")]
35+
[string]$TextType = "EnhancedRichText",
36+
37+
[Parameter(Mandatory = $true)]
38+
[ValidateSet("Yes", "No")]
39+
[string]$AppendOnly = "Yes"
40+
)
41+
42+
# Connect to SharePoint site
43+
Connect-PnPOnline -Url $Url
44+
45+
# Map the TextType to corresponding RichTextMode and RichText values
46+
switch ($TextType) {
47+
"EnhancedRichText" {
48+
$RichTextMode = "FullHtml"
49+
$RichText = $true
50+
}
51+
"PlainText" {
52+
$RichTextMode = "Compatible"
53+
$RichText = $false
54+
}
55+
"RichText" {
56+
$RichTextMode = "Compatible"
57+
$RichText = $true
58+
}
59+
}
60+
61+
# Convert AppendOnly parameter to boolean
62+
$AppendOnlyValue = if ($AppendOnly -eq "Yes") { $true } else { $false }
63+
64+
# Update field properties
65+
Set-PnPField -List $ListName -Identity $FieldName -Values @{
66+
AppendOnly = $AppendOnlyValue
67+
RichTextMode = $RichTextMode
68+
RichText = $RichText
69+
NumLines = "6"
70+
UnlimitedLengthInDocumentLibrary = $false
71+
} -ErrorAction Stop
72+
73+
# Handle properties that cannot be updated directly
74+
$Field = Get-PnPField -List $ListName -Identity $FieldName -ErrorAction Stop
75+
$FieldSchemaXml = [xml]$Field.SchemaXml
76+
77+
if ($TextType -eq "EnhancedRichText" -or $TextType -eq "RichText") {
78+
$FieldSchemaXml.Field.SetAttribute("RichTextMode", $RichTextMode)
79+
$FieldSchemaXml.Field.SetAttribute("NumLines", "8")
80+
}
81+
82+
Set-PnPField -List $ListName -Identity $FieldName -Values @{
83+
SchemaXml = $FieldSchemaXml.OuterXml
84+
} -ErrorAction Stop
85+
```
86+
87+
[!INCLUDE [More about PnP PowerShell](../../docfx/includes/MORE-PNPPS.md)]
88+
89+
***
90+
91+
## Source Credit
92+
93+
Sample first appeared on [Updating Multiline Text Field Properties in SharePoint Using PowerShell](https://reshmeeauckloo.com/posts/powershell-sharepoint-multilinefield-appendtext/)
94+
95+
## Contributors
96+
97+
| Author(s) |
98+
|-----------|
99+
| [Reshmee Auckloo](https://github.com/reshmee011) |
100+
101+
102+
[!INCLUDE [DISCLAIMER](../../docfx/includes/DISCLAIMER.md)]
103+
<img src="https://m365-visitor-stats.azurewebsites.net/script-samples/scripts/spo-multiline-field-properties" aria-hidden="true" />
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
[
2+
{
3+
"name": "spo-multiline-field-properties",
4+
"source": "pnp",
5+
"title": "Updating Multiline Text Field Properties in SharePoint",
6+
"shortDescription": "Updating Multiline Text Field Properties in SharePoint",
7+
"url": "https://pnp.github.io/script-samples/spo-multiline-field-properties/README.html",
8+
"longDescription": [
9+
"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."
10+
],
11+
"creationDateTime": "2025-05-07",
12+
"updateDateTime": "2025-05-07",
13+
"products": [
14+
"SharePoint",
15+
"Libraries"
16+
],
17+
"metadata": [
18+
{
19+
"key": "PNP-POWERSHELL",
20+
"value": "3.0"
21+
}
22+
],
23+
"categories": [
24+
"SharePoint"
25+
],
26+
"tags": [
27+
"modern",
28+
"Connect-PnPOnline",
29+
"Get-PnPField",
30+
"Set-PnPField"
31+
],
32+
"thumbnails": [
33+
{
34+
"type": "image",
35+
"order": 100,
36+
"url": "https://raw.githubusercontent.com/pnp/script-samples/main/scripts/spo-multiline-field-properties/assets/preview.png",
37+
"alt": ""
38+
}
39+
],
40+
"authors": [
41+
{
42+
"gitHubAccount": "reshmee011",
43+
"company": "",
44+
"pictureUrl": "https://avatars.githubusercontent.com/u/7693852?v=4",
45+
"name": "Reshmee Auckloo"
46+
}
47+
],
48+
"references": [
49+
{
50+
"name": "Want to learn more about PnP PowerShell and the cmdlets",
51+
"description": "Check out the PnP PowerShell site to get started and for the reference to the cmdlets.",
52+
"url": "https://aka.ms/pnp/powershell"
53+
}
54+
]
55+
}
56+
]

0 commit comments

Comments
 (0)