SharePoint list filter multiple lines of text

SharePoint Online: Add Multiple Lines of Text Column to List using PowerShell

July 6, 2021 0 Comments

The Multiple Lines of Text column in SharePoint Online is used to store Multiple rows of Text value. Based on the field settings, it can contain Rich text, including text, images, HTML formatted values, etc.

How to Add Multiple Lines of Text Field to List in SharePoint Online?

  • Browse to your SharePoint Online site and Navigate to the target list in which you want to add Choice column.
  • Under the List tab, click on Create Column button in the ribbon.
  • Provide the Name to your new column, specify the type as Multiple lines of text
  • Fill other optional values such as Number of lines, Type of text, append changes to existing text, etc. and Click on OK to create Multiple lines of text column in SharePoint Online list.

PowerShell to Create Multiple Lines of Text Column in SharePoint Online List:

#Load SharePoint CSOM Assemblies Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" #Custom function to add column to list Function Add-MultilineTextColumnToList[] { param [ [Parameter[Mandatory=$true]] [string] $SiteURL, [Parameter[Mandatory=$true]] [string] $ListName, [Parameter[Mandatory=$true]] [string] $Name, [Parameter[Mandatory=$true]] [string] $DisplayName, [Parameter[Mandatory=$false]] [string] $Description=[string]::Empty, [Parameter[Mandatory=$false]] [string] $IsRequired = "FALSE", [Parameter[Mandatory=$false]] [string] $IsRichText="FALSE", [Parameter[Mandatory=$false]] [string] $NumLines = "6", [Parameter[Mandatory=$false]] [string] $EnhancedRichText = "FALSE" ] #Generate new GUID for Field ID $FieldID = New-Guid Try { $Cred= Get-Credential $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials[$Cred.Username, $Cred.Password] #Setup the context $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext[$SiteURL] $Ctx.Credentials = $Credentials #Get the List $List = $Ctx.Web.Lists.GetByTitle[$ListName] $Ctx.Load[$List] $Ctx.ExecuteQuery[] #Check if the column exists in list already $Fields = $List.Fields $Ctx.Load[$Fields] $Ctx.executeQuery[] $NewField = $Fields | where { [$_.Internalname -eq $Name] -or [$_.Title -eq $DisplayName] } if[$NewField -ne $NULL] { Write-host "Column $Name already exists in the List!" -f Yellow } else { #Define XML for Field Schema if[$EnhancedRichText -eq "TRUE"] #Enhanced Rich Text Mode { $FieldSchema = "" } else #Plain Text or Rich Text { $FieldSchema = "" } $NewField = $List.Fields.AddFieldAsXml[$FieldSchema,$True,[Microsoft.SharePoint.Client.AddFieldOptions]::AddFieldInternalNameHint] $Ctx.ExecuteQuery[] Write-host "New Column Added to the List Successfully!" -ForegroundColor Green } } Catch { write-host -f Red "Error Adding Column to List!" $_.Exception.Message } } #Set parameter values $SiteURL="//crescent.sharepoint.com" $ListName="Projects" $Name="ProjectDescription" $DisplayName="Project Description" $Description="Enter the Project Description" $IsRichText="FALSE" #FALSE for Plain text / TRUE for Rich text $EnhancedRichText="FALSE" #FALSE for Rich text / TRUE for Enhanced Rich Text, Takes Precedence over IsRichText parameter value #Call the function to add column to list Add-MultilineTextColumnToList -SiteURL $SiteURL -ListName $ListName -Name $Name -DisplayName $DisplayName -Description $Description -IsRichText $IsRichText -EnhancedRichText $EnhancedRichText

PnP PowerShell to Add a Multi-line Text Field to SharePoint Online List

#Config Variables $SiteURL = "//crescenttech.sharepoint.com/sites/marketing" $ListName= "Projects" #Connect to PnP Online Connect-PnPOnline -Url $SiteURL -Credentials [Get-Credential] #Add Multiple lines of Text Field to list Add-PnPField -Type Note -List $ListName -DisplayName "Project Description" -InternalName "ProjectDescription" -AddToDefaultView

Similarly, you can add a multi-line text field to SharePoint Online List from XML schema.

#Define XML Schema for Multiline Text Field $FieldXML= "" #Add Choice Field to list from XML Add-PnPFieldFromXml -FieldXml $FieldXML -List $ListName

Related Posts

Video liên quan

Chủ Đề