SharePoint Online: PowerShell kullanarak Çok Satırlı Metin Alanı Türünü Zengin Metin Olarak Değiştirme
Gereksinim: SharePoint Online'da Çok Satırlı Metin Alanı türünü Zengin Metin olarak değiştirin.
Çok Satırlı Metin Alanı Türünü Düz Metinden Zengin Metine Nasıl Değiştiririm?
Çok satırlı metin alanı türü düz metin olarak ayarlanmışsa, bu durum kullanıcıların kullanabileceği biçimlendirme seçeneklerini sınırlar. Ancak, alan ayarlarını veya kalınlaştırma, italikleştirme ve köprü oluşturma gibi ek biçimlendirme seçenekleri sağlayan PowerShell'i kullanarak birden çok satırlık metin alanı türünü Gelişmiş Zengin Metin olarak değiştirmek mümkündür. Bu yazımızda çok satırlı metin alanı tipini Zengin Metin olarak nasıl değiştireceğinizi göstereceğiz.
SharePoint Online'da düz metinden zengin metne veya geliştirilmiş zengin metne geçiş oldukça basittir:
- Hedef sütunun bulunduğu listeye veya siteye gidin. Sütun ayarlarına girin.
Gereksinimlerinize göre sütun türünü "Zengin Metin (Kalın, italik, metin hizalaması, köprüler)" veya "Gelişmiş zengin metin (Resimler, tablolar ve köprüler içeren zengin metin)" olarak seçin.
- Değişikliklerinizi kaydetmek için “Tamam”a tıklayın.
PowerShell, SharePoint Online'da Çok Satırlı Metin Sütunu türünü "Zengin Metin" olarak Ayarlamak için:
#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"
#Function to Set Multiple Lines of Text Field Type to "Rich Text"
Function Set-SPOMultilineTextType([String]$SiteURL,[String]$ListName, [String]$FieldInternalName)
{
Try {
#Get credentials to connect
$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 & Fields
$List = $Ctx.Web.lists.GetByTitle($ListName)
$Ctx.Load($List)
$ListFields = $List.Fields
$Ctx.Load($ListFields)
$Ctx.ExecuteQuery()
#Get the Field to Update
$FieldToUpdate = $ListFields | Where {$_.InternalName -eq $FieldInternalName}
If($FieldToUpdate -ne $NULL)
{
#Update the Field Settings
$FieldToUpdate.RichText = $True
$FieldToUpdate.Update()
$Ctx.ExecuteQuery()
write-host -f Green "Field '$($FieldToUpdate.Title)' Updated in List '$($List.Title)' Successfully!" $_.Exception.Message
}
}
Catch {
write-host -f Red "Error Updating Field Settings!" $_.Exception.Message
}
}
#Config Parameters
$SiteURL="https://Crescent.sharepoint.com"
$ListName="Projects V1"
$FieldInternalName="Project_x0020_Description"
#Call the function
Set-SPOMultilineTextType -SiteURL $SiteURL -ListName $ListName -FieldInternalName $FieldInternalName
Tüm çok satırlı metin alanlarını bir SharePoint Online sitesindeki zengin metin sütununa dönüştürmek isterseniz ne olur? Aşağıdaki PowerShell betiğiyle tüm listelerde ve kitaplıklarda birden çok satırlık metin alanını dönüştürebilirsiniz:
#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"
#Function to convert Multiple Lines of Text Field Type to "Rich Text"
Function Set-AllSPOMultilineTextType([String]$SiteURL)
{
Try {
#Get credentials to connect
$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 all lists
$Lists = $Ctx.web.Lists
$Ctx.Load($Lists)
$Ctx.ExecuteQuery()
#Iterate through each list
ForEach($List in $Lists | Where {$_.Hidden -eq $False})
{
#Get AllowDeletion Property to filter system lists
$List.Retrieve("AllowDeletion")
$Ctx.ExecuteQuery()
If($List.AllowDeletion -eq $True)
{
#Get All List Fields
$ListFields = $List.Fields
$Ctx.Load($ListFields)
$Ctx.ExecuteQuery()
ForEach($Field in $ListFields)
{
If($Field.TypeDisplayName -eq "Multiple lines of text" -and $Field.hidden -eq $False -and $Field.ReadOnlyField -eq $False)
{
#Update the Field Settings
$FieldToUpdate.RichText = $True
$FieldToUpdate.Update()
$Ctx.ExecuteQuery()
write-host -f Green "Field '$($Field.Title)' Updated in List '$($List.Title)' Successfully!" $_.Exception.Message
}
}
}
}
}
Catch {
write-host -f Red "Error Updating Field Settings!" $_.Exception.Message
}
}
#Config Parameters
$SiteURL="https://Crescent.sharepoint.com"
#Call the function
Set-AllSPOMultilineTextType -SiteURL $SiteURL
Bu, yazı tipi renkleri, tablolar vb. gibi ek biçimlendirme seçeneklerini etkinleştirir.
PowerShell'i kullanarak Zengin Metin Alanını Gelişmiş Zengin Metin Alanına dönüştürün:
Geliştirilmiş zengin metin alanına birden çok satırlık metin alanı tipi yapmak için önce alanı düz metinden “Zengin Metin”e dönüştürmeliyiz (“RichTextMode” özelliğinin dolması için) ve ardından alan şemasını değiştirmeliyiz.
#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"
#Function to Set Multiple Lines of Text Rich Text Field Type to "Enhanced Rich Text"
Function Set-SPOMultilineRichTextToEnhanced([String]$SiteURL, [String]$ListName, [String]$FieldInternalName)
{
Try {
#Get credentials to connect
$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 & Fields
$List = $Ctx.Web.lists.GetByTitle($ListName)
$Ctx.Load($List)
$ListFields = $List.Fields
$Ctx.Load($ListFields)
$Ctx.ExecuteQuery()
#Get the Field to Update
$FieldToUpdate = $ListFields | Where {$_.InternalName -eq $FieldInternalName}
If($FieldToUpdate -ne $NULL)
{
If($FieldToUpdate.RichText -eq $True)
{
#Enable Enhanced Rich Text
$FieldToUpdate.SchemaXml = $FieldToUpdate.SchemaXml.Replace("RichTextMode=`"Compatible`"","RichTextMode=`"FullHtml`"")
$FieldToUpdate.Update()
$Ctx.ExecuteQuery()
write-host -f Green "Field '$($FieldToUpdate.Title)' Updated in List '$($List.Title)' Successfully!" $_.Exception.Message
}
else
{
write-host -f Yellow "Field '$($FieldToUpdate.Title)' Should be a Rich Text Field in order to Make it Enhanced Rich Text!" $_.Exception.Message
}
}
else
{
write-host -f Yellow "Field '$($FieldToUpdate.Title)' doesn't exist in the List!" $_.Exception.Message
}
}
Catch {
write-host -f Red "Error Updating Field Settings!" $_.Exception.Message
}
}
#Config Parameters
$SiteURL="https://Crescent.sharepoint.com"
$ListName="Projects V1"
$FieldInternalName="Project_x0020_Description"
#Call the function
Set-SPOMultilineRichTextToEnhanced -SiteURL $SiteURL -ListName $ListName -FieldInternalName $FieldInternalName
Bu adımları tamamladıktan sonra, çok satırlı metin alanı türü Zengin Metin olarak ayarlanacaktır ve görsel olarak daha çekici ve ilgi çekici içerik oluşturmak için yeni biçimlendirme seçeneklerini kullanmaya başlayabilirsiniz.
