locked
How to set Document Set Welcome page view property via powershell RRS feed

  • Question

  • Hi all,

    I am trying to set Document Set's Welcome page view dropdown with my custom view via Powershell. However, below code seems be not working. Anybody have any workaround? $xmldoc.Contains("WelcomePageView")) xmldoc object do not contain "WelcomePageview".

    function SetWelcomePageView()
    {
    $contenttype=$lib.ContentTypes["DocumentIT"]
    $viewid = $lib.Views["zzzDocSetView"].Id
    $xmldocs = $contenttype.XmlDocuments
    Write-Host $xmldocs
    foreach($xmldoc in $xmldocs)
    {
    	if($xmldoc.Contains("WelcomePageView"))
    	{
    		Write-Host "XML contains WPV"  
            $newview =  [XML] @"
    <wpv:WelcomePageView xmlns:wpv="http://schemas.microsoft.com/office/documentsets/welcomepageview" ViewId="$viewid" />
    "@
    		$xmldocs.Delete("http://schemas.microsoft.com/office/documentsets/welcomepageview")
    		$xmldocs.Add($newview)
    		break;
    	}
    }
    $contenttype.Update($updateChildren, $false)
    Write-Host "Welcome Page View updated at " $list.Title
    }

    Wednesday, September 2, 2015 8:17 AM

Answers

  • Hi,

    Please make sure the "DocumentID" is a document set content type. The following code working in my test environment.

    $web = Get-SPWeb "http://sp2013sps:8080"
    $list = $web.Lists["Documents"]   
    $contenttype = $list.ContentTypes["Document Set"]     
    $viewid = $list.Views["zzzDocSetView"].Id
    $xmldocs = $contenttype.XmlDocuments
    foreach($xmldoc in $xmldocs)
    {
    	if($xmldoc.Contains("WelcomePageView"))
    	{
    		Write-Host "XML contains WPV"  
            $newview =  [XML] @"
    <wpv:WelcomePageView xmlns:wpv="http://schemas.microsoft.com/office/documentsets/welcomepageview" ViewId="$viewid" />
    "@
    		$xmldocs.Delete("http://schemas.microsoft.com/office/documentsets/welcomepageview")
    		$xmldocs.Add($newview)
    		break;
    	}
    }
    $contenttype.Update($updateChildren, $false)

    Best Regards,

    Dennis


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    • Proposed as answer by Hemendra Agrawal Wednesday, September 16, 2015 9:36 AM
    • Marked as answer by Patrick_Liang Monday, September 21, 2015 3:15 AM
    Thursday, September 3, 2015 7:23 AM

All replies

  • This is a function... you are calling the function, right?

    As in..  after the last } you have:

    SetWelcomePageView



    If this is helpful please mark it so. Also if this solved your problem mark as answer.

    Wednesday, September 2, 2015 12:33 PM
  • Hi,

    Please make sure the "DocumentID" is a document set content type. The following code working in my test environment.

    $web = Get-SPWeb "http://sp2013sps:8080"
    $list = $web.Lists["Documents"]   
    $contenttype = $list.ContentTypes["Document Set"]     
    $viewid = $list.Views["zzzDocSetView"].Id
    $xmldocs = $contenttype.XmlDocuments
    foreach($xmldoc in $xmldocs)
    {
    	if($xmldoc.Contains("WelcomePageView"))
    	{
    		Write-Host "XML contains WPV"  
            $newview =  [XML] @"
    <wpv:WelcomePageView xmlns:wpv="http://schemas.microsoft.com/office/documentsets/welcomepageview" ViewId="$viewid" />
    "@
    		$xmldocs.Delete("http://schemas.microsoft.com/office/documentsets/welcomepageview")
    		$xmldocs.Add($newview)
    		break;
    	}
    }
    $contenttype.Update($updateChildren, $false)

    Best Regards,

    Dennis


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    • Proposed as answer by Hemendra Agrawal Wednesday, September 16, 2015 9:36 AM
    • Marked as answer by Patrick_Liang Monday, September 21, 2015 3:15 AM
    Thursday, September 3, 2015 7:23 AM