2017-09-18 28 views
-1

複数行のリッチテキストフィールドであるSharePoint OnlineのSharePointアドインにリスト列があります。 Power-Shellを使用してEnhance Rich Textフィールドに変換します。PowerShellを使用してSharePointリッチテキストのマルチラインフィールドを強化リッチテキストに更新する方法

$ URL、$ Username、$ passwordおよび$ ListTitleは、このコードが記述されている関数にパラメータとして渡されます。私は私が最終的に強化されたリッチテキストにSharePointのアドインリストの複数行フィールドを更新する問題を解決することができた数日間に苦労した後$item

+0

CompatibleからRichTextModeを交換する必要が

は、あなたがこれまでにしようとしているものを、あなたのコードを入力してください。 – JustBaron

+0

これまでに試したコードを追加しました – SudarshanJ

答えて

0

存在しない$item.RichTextMode = "FullHtml"RichTextModeとしての性質を使用することはできません

try 
{ 
    $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url) 
    $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $password) 
    $ctx.Load($ctx.Web) 
    $ctx.ExecuteQuery() 
    $ll=$ctx.Web.Lists.GetByTitle($ListTitle) 
    $ctx.Load($ll) 
    $ctx.ExecuteQuery() 
    #Add new field to the list 
    Write-Host "`nGot List" $ListTitle 

    $fieldColl = $ll.Fields; 

    $isDescriptionPlainText = $false; 
    $ctx.Load($fieldColl); 
    $ctx.ExecuteQuery(); 
    foreach ($item in $fieldColl) 
    { 
     if($item.InternalName -eq "VisualDescription") 
     { 

      if($item.InternalName -eq "VisualDescription" -and $item.RichText -eq $false) 
      { 
       Write-Host ("`n'{0}' Field available.Making Rich Text"-f $item.InternalName) 
       $msg=("`n'{0}' Field available.Making Rich Text"-f $item.InternalName) 
       writeToLog $msg 
       $isDescriptionPlainText=$true; 
       $item.RichText = $true 
       $item.update() 
      } 
      else 
      { 
       Write-Host ("`n Field not available or already a rich text.") 
       $msg=("Field not available or already a rich text.") 
       writeToLog $msg 
      } 
     }   
    } 
    if($isDescriptionPlainText) 
    { 
     $ll.update() 
     $ctx.Load($ll) 
     $ctx.ExecuteQuery() 
    } 
} 
catch 
{ 
    $errorMessage = $_.Exception.Message 
    $errLineNumber = $_.InvocationInfo.ScriptLineNumber 
    $errOffset = $_.InvocationInfo.OffsetInLine 
    $msg = "The script failed due to an unexpected error. [Reason]: $errorMessage [Error Line Number]: $errLineNumber ($errOffset)" 
    writeErrorToLog $msg 
    # Log the entire stack trace 
    writeErrorToLog $_.Exception 
    Write-Error $msg 
} 

PowerShellを使用します。我々は、フィールドのSchemaXMLプロパティで変更を行い、FullHtml

$item.SchemaXml=$item.SchemaXml.Replace("RichTextMode=`"Compatible`"","RichTextMode=`"FullHtml`"") 
関連する問題