SharePoint Online: Change Multiple Lines of Text Field Type to Rich Text using PowerShell

Requirement: Change Multiple Lines of Text Field type to Rich Text in SharePoint Online.

How to Change Multiple Lines of Text Field Type from Plain Text to Rich Text?

If the Multiple lines of text field type is set to plain text, that limits the formatting options available to users. However, it is possible to change the multiple lines of text field type to Enhanced Rich Text using field settings or PowerShell, which provides additional formatting options such as bolding, italicizing, and hyperlinking. In this article, we will show you how to change the multiple lines of text field type to Rich Text.

Switching from plain text to rich text or enhanced rich text in SharePoint Online is quite simple:

  1. Go to the list or site where the target column exists. Get into the column settings.
  2. Select the column type to “Rich Text (Bold, italics, text alignment, hyperlinks)” or “Enhanced rich text (Rich text with pictures, tables, and hyperlinks)” as per your requirement.change multiple lines of text field type to rich text
  3. Click on “OK” to save your changes.

PowerShell to Set Multiple Lines of Text Column type to “Rich Text” in SharePoint Online:

#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

What if you want to convert all multi-line text fields to a rich text column in a SharePoint Online site? You can convert multiple lines of text fields in all lists and libraries with this below PowerShell script:

#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 

This will enable additional formatting options such as font colors, tables, etc.

Convert Rich Text Field to Enhanced Rich Text Field using PowerShell:

To make multiple lines of text field type to the enhanced rich text field, we should convert the field to “Rich Text” first (So that the “RichTextMode” attribute populates) from plain text and then change the field schema. 

#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

Once you have completed these steps, the multiple lines of text field type will be set to Rich Text, and you can start using the new formatting options to create more visually appealing and engaging content.

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

One thought on “SharePoint Online: Change Multiple Lines of Text Field Type to Rich Text using PowerShell

  • Hi there, I’m looking to convert RichTextMode=Compatible into Plain text mode. Are you able to assist? I can’t seem to find any reference to this anywhere on the web. thanks

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *