Partager via


Working-around “SocialCommentWebPart Title property not working”

 

A client recently hit the issue described in this post, SocialCommentWebPart Title property not working.

Basically, the Title set in the person.aspx to the SocialCommentWebPart is not being honored e.g., <SPSWC:SocialCommentWebPart Title="New Title" …>

One workaround I found is to edit the web part in shared mode and set its title. Because this was needed to be configured during deployment, I wrote the following snippet:

$s = new-object Microsoft.SharePoint.SPSite("https://server/sites/mysitehost")
$page = $s.RootWeb.GetFile("person.aspx")
if($page.CheckOutType -eq 'None')
{
  $page.CheckOut()
}
$wpm = $web.GetLimitedWebPartManager("person.aspx", [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
$wp = $null
$wpm.WebParts | where {$_.WebBrowsableObject.GetType().Name -eq 'SocialCommentWebPart'} | % {$wp = $_}
$wp.Title = "Nuevo titulo"
$wpm.SaveChanges($wp)
$page.CheckIn("Title Changed")
$s.Close()