вівторок, 23 січня 2018 р.

New-SPSite Error 0x8007007b

I was trying to create a new site collection in a new content database. This can be accomplished using PS cmdlets like this:
$server = "Database Server Name"
$dbname = "Database Name"
$webapp = "https://myapp.com/"
$site = "https://myapp.com/sites/newsite"
$owner1 = "mydomain\siteowner"
New-SPContentDatabase -Name $dbname -DatabaseServer $server -WebApplication $webapp
New-SPSite -URL $site -OwnerAlias $owner1 -ContentDatabase $dbname
First, I created a new database. Then a new site collection. As I didn't use -Template parameter with New-SPSite cmdlet I had to choose a template when I first opened "https://myapp.com/sites/newsite" site. I chose "Project Site" and after template selection I got error message "File not found...". Using correlation id I was trying to determine what was missing, among all logs I found only few lines that was interesting:
Unknown SPRequest error occurred. More information: 0x80070002
0x80070002
...
Unknown SPRequest error occurred. More information: 0x8007007b
0x8007007b
Which didn't help much. Then I tried to call New-SPSite passing -Template parameter and got similar error message:
New-SPSite : 0x8007007b
At line:3 char:1
+ New-SPSite -URL $site -OwnerAlias $owner1 -ContentDatabase "Database Name" -Templa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (Microsoft.Share...SPCmdletNewSite:SPCmdletNewSite) [New-SPSite], SPException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletNewSite
So I started looking for this particular error
New-SPSite : 0x8007007b
Fortunately I found this blog https://www.communardo.de/techblog/sharepoint-2013-april-cu-und-warum-sie-es-installieren-sollten/ It's in German which I don't understand but it pointed me to simple solution that helped - just use New-SPSite with -Name parameter! So, if you are using old enough version of SP, ours is 15.0.4569.1000, and having this error, try to pass -Name parameter to New-SPSite cmdlet:
New-SPSite -URL $site -OwnerAlias $owner1 -ContentDatabase $dbname -Name "New Site Name"

четвер, 30 листопада 2017 р.

Asset library Video content type

Hi there!

If you have ever tried to upload a video to Asset Library you might have noticed its different behavior compared to Documents Library.

When you have uploaded the video you will find that the file itself is located inside additional "folder". This additional folder is actually a Document Set not a simple folder.
You set the name for this DocSet when you create Video item. But the video file will be saved with its original file name. So it is better to rename the file before uploading if you want nice URL.

One interesting thing is that when you try to open this Video item in Explorer, using menu action on the Library tab, Explorer will actually open "Additional Content" folder which is created inside the DocSet when you create the Video item.
Also when you put something to "Related" it will appear in this Additional Content folder not inside the Video DocSet.

To be honest I can't understand where does this magic happen.
If you open DocSet "home" page, which is AssetsLib/Forms/Video/videoplayerpage.aspx by default, you will find OfficeServer:DocumentSetContentsWebPart which is used to show content of the usual DocSet, but in case with Video content type it shows content inside Additional Content folder inside DocSet.

Also, if you look through browser's log, you might see some redirections. For example:

GET
.../TestAssetsLib/Test%20clip

HTTP 302 Redirect
Location: 
.../_layouts/15/DocSetHome.aspx?id=/TestAssetsLib/Test%20clip
&RootFolder=/TestAssetsLib/Test%20clip

GET
.../_layouts/15/DocSetHome.aspx?id=/TestAssetsLib/Test%20clip
&RootFolder=/TestAssetsLib/Test%20clip

HTTP 302 Found
Location: 
.../TestAssetsLib/Forms/Video/videoplayerpage.aspx?ID=4
&FolderCTID=0x0120D520A8080048096958098E9546A5AF9E5EF12F8411
&List=c4fdc911-1976-4016-84dc-d09c5e4b6dd5
&RootFolder=/TestAssetsLib/Test%20clip/Additional%20Content
&RecSrc=/TestAssetsLib/Test%20clip

GET
.../TestAssetsLib/Forms/Video/videoplayerpage.aspx?ID=4
&FolderCTID=0x0120D520A8080048096958098E9546A5AF9E5EF12F8411
&List=c4fdc911-1976-4016-84dc-d09c5e4b6dd5
&RootFolder=/TestAssetsLib/Test%20clip/Additional%20Content
&RecSrc=/TestAssetsLib/Test%20clip

HTTP 200 OK

So somewhere server sets RootFolder to Additional Content folder.

If you know something interesting about this, please comment! =)

пʼятниця, 24 листопада 2017 р.

Passing value to WebPart xsl

Sometimes you need to customize a SharePoint web part's appearance on a page, for example you want special look for ContentByQueryWebPart.To do that you can customize few xsl files (ContentQueryMain.xsl, ItemStyle.xsl). There are a plenty of articles about it over the Internet, so I won't talk about this in details.
But what if you want to use some value from the page in your xsl? Luckily there is a way to pass it using ParameterBindings element.

The code below allows you to pass different types of values to your xsl:
<WpNs0:ContentByQueryWebPart ...
WebPartAttributeName="WebPartAttributeValue" >
  ...
  <ParameterBindings>
    <ParameterBinding Name="StaticValue"
      DefaultValue="240px" />
    <ParameterBinding Name="WebPartAttribute"
      Location="WPProperty(WebPartAttributeName)" />
  </ParameterBindings>
</WpNs0:ContentByQueryWebPart>
To use this in your xsl define variables and use them:
<xsl:param name="StaticValue" />
<xsl:param name="WebPartAttribute" />
...
<h1 class="{$StaticValue}">
  <value-of select="$WebPartAttribute" />
</h1>
You can read more about ParameterBinding element here