SharePoint list filter multiple lines of text
Ngày đăng:
07/12/2021
Trả lời:
0
Lượt xem:
232
Show
SharePoint Online: Add Multiple Lines of Text Column to List using PowerShellJuly 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?
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 = " PnP PowerShell to Add a Multi-line Text Field to SharePoint Online List#Config Variables
$SiteURL = "https://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= " Related Posts |