How to rich text column properties update using pnp js

Lakshmi Lahari Tumpala 0 Reputation points

Hi Team,

I want to update existing rich text field to enhanced rich text field without losing data in the column using pnp js

A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,263 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 33,641 Reputation points Microsoft Vendor

    Hi @Lakshmi Lahari Tumpala

    Per my research, there is no such function to update a column's properties. You can refer to the functions available in pnp/js. As a workaround, I wil recommend you to use powershell to reach your requirement. Please refer to the following 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 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)
            $ListFields = $List.Fields
            #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`"")
                    write-host -f Green "Field '$($FieldToUpdate.Title)' Updated in List '$($List.Title)' Successfully!" $_.Exception.Message
                    write-host -f Yellow "Field '$($FieldToUpdate.Title)' Should be a Rich Text Field in order to Make it Enhanced Rich Text!" $_.Exception.Message
                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
    $ListName="Projects V1"
    #Call the function
    Set-SPOMultilineRichTextToEnhanced -SiteURL $SiteURL -ListName $ListName -FieldInternalName $FieldInternalName

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.