How To Set Title to Required in Document Libraries   Leave a comment

SharePoint SearchThe SharePoint Search Service Crawler and Indexer uses the “Title” property first when content is indexed.  A new feature in SharePoint 2016 has the crawler picking up the first line or “header” of the document to help with indexing content.  By adding a Title to documents, SharePoint search will provide a better UX (User Experience) with SharePoint’s Search Results when users are searching for content.

By default the Title content in Document Libraries is not required, leaving many lazy users not filling out this field.  This could potentially give incorrect search results or results that are confusing.

You can easily set the Title to Required by going into the Document Content Type, but if there are many Libraries in Sites and Site Collections that could be cumbersome.

You can create a Feature (List Event Receiver) when a Library is provisioned to set the Title to required, and for existing libraries that can also be accomplished via PowerShell.

In this example, I have the Title property set during the provisioning process.

Public Class TitleRequired
Inherits SPListEventReceiver
”’
”’ A list was added.
”’

Public Overrides Sub ListAdded(properties As SPListEventProperties)
MyBase.ListAdded(properties)

Dim sSiteUrl As String = properties.Web.Site.Url
Dim sWebUrl As String = properties.Web.Url
Dim sLibraryName As String = properties.ListTitle
‘*************************************************************************************************
‘Note: Making the Title Column (Field) Required in a Document Library is Different from a
‘      Custom List.  The “Document” Content Type Associated with the List requires the Change.

‘      If Deactivating this Feature, you will need to Manually Set the Title Required proprety
‘      through the “Document Content Type” under “Allow Management of Content Types”.
‘*************************************************************************************************
Try
Using site As New SPSite(sSiteUrl)
Using web As SPWeb = site.OpenWeb()
                 Dim list As SPList = web.Lists.TryGetList(sLibraryName)
Dim contentType As SPContentType = list.ContentTypes(“Document”)
Dim titleField As SPField = list.Fields(“Title”)
Dim fieldLink As SPFieldLink = contentType.FieldLinks(titleField.Id)
web.AllowUnsafeUpdates = True
                fieldLink.Required = True
contentType.Update()
web.AllowUnsafeUpdates = False
            End Using
End Using
Catch ex As Exception
‘Throw a message in the ULS Logging
Microsoft.Office.Server.Diagnostics.PortalLog.LogString(“Exception Occurred ATI.SP.ER.SetTitleRequired: {0} || {1}”, ex.Message, ex.StackTrace)
End Try
End Sub
End Class

Posted June 29, 2017 by Bismarck in SharePoint 2013, SharePoint 2016

How To Resolve Issue Opening Visual Studio 2015 Projects in Visual Studio 2017   Leave a comment

I recently upgraded to the new Microsoft Visual Studio 2017.  When I tried to open projects created in the earlier version (Visual Studio 2015), I encountered a running issue where it continuously asked to install the Visual Studio Tools for Office.  The problem was that they are already installed with Visual Studio 2017 when I selected the Office Tools & SharePoint products during the Install.

It seems the versioning has not been updated correctly during either the Migration, or the Upgrade. Since this product is so new, I don’t know if this is the official remedy but here is how I fixed it.

Solution:

Open the Project File (e.g. .vbproj or .csproj) file and update the “MinimumOfficeToolsVersion” to 14.   Sometimes I noticed the value varied from 14.5 to 14.6

Happy SharePointing!

Posted March 14, 2017 by Bismarck in SharePoint 2016

How To Resolve Publishing Pages Not Created in the Correct Location   Leave a comment

Problem

You may have come across this issue in your Intranet. Let’s say you create your Intranet with several Sub-Sites and utilize the Managed Metadata Navigation to manage the Top Link Bar. This Managed Metadata Navigation is inherited across and down through all of the Sub-Sites.

howtoresolvepublishingpageslocation_pic1

Now, when you click on the ‘Add a Page’ from the “Find it at: <URL>” displays the wrong address or at most the <Root> of the Site Collection.

howtoresolvepublishingpageslocation_pic2

What you want to happen in a Publishing site, is to have the New Pages Added, added to the Pages library of the site or Sub-Site you are creating it from.

Resolution

Uncheck the “Create friendly URLs for new pages automatically” in the Navigation Settings of the Site or Sub-Site should resolve this issue.

howtoresolvepublishingpageslocation_pic3

Result:

howtoresolvepublishingpageslocation_pic4

Note:

If you have the Publishing Infrastructure and Publishing Feature enabled on a Team Site, it will default to “/SitePages”. This is because by default the “Wiki Page Home Page” Site feature is enabled by default when a Team Site is provisioned. Simply Disable this feature and your New Pages will be added to the “/Pages” Library.

Happy SharePointing!

Posted December 16, 2016 by Bismarck in SharePoint 2013, SharePoint 2016

How To Remove the Recent Node on the Quick Launch without Code in SharePoint 2016   Leave a comment

You can remove the Recent Node in the Quick Launch (Current Navigation) in SharePoint 2016 without having to write code or deploy CSS changes.  This should also work on SharePoint 2013 as well.

Steps

  1. First create a New SharePoint Security Group in your Site Collection.  This group only needs “Read” permissions.

PeopleAndGroups

2. From “Site Settings”, “Navigation”, select the Recent Link in the Current Navigation section and click on the “Edit” menu item in the Navigation box.

Navigation

3. Next, select the “Target Audience” and add the New SharePoint Permission Group you created.

That’s it.  Now all you have to do is Add users to your new group if they need to see the “Recent Node”

Posted May 11, 2016 by Bismarck in SharePoint 2013, SharePoint 2016

How To Add a Feature Stapler to My Sites and Change the Blog Title   Leave a comment

I’ve been working with SharePoint 2013 for some time now and now eagerly reviewing the new SharePoint 2016.  I noticed that when users provision their Blogs on their My Sites, the title default to “Welcome to My Blog”.  The eventual result of this becomes more apparent when they show up in the search results.

Here I decided to incorporate a feature stapler while working on a custom branded My Sites Masterpage.  This feature will, when a My Site Blog is provisioned, renames the Blog Title to “Welcome to <DisplayName>’s Blog.  Now when you search on Blogs it makes it more clear as to who blog it is.

So I in my Visual Studio Project, I created an Event Handler called “MySiteWebProvisioning” with the following code:

Imports System
Imports System.Security.Permissions
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Utilities
Imports Microsoft.SharePoint.Workflow
Imports Microsoft.Office.Server

Public Class MySiteWebProvisioning
Inherits SPWebEventReceiver

”’ <summary>
”’ A site was provisioned.
”’ </summary>
Public Overrides Sub WebProvisioned(properties As SPWebEventProperties)
MyBase.WebProvisioned(properties)

Using targetWeb As SPWeb = properties.Web
Using rootWeb As SPWeb = targetWeb.Site.RootWeb

‘******************************************************************************************
‘* Set MySite Blog Title to Display Name’s – Blog.  When these MySite Blogs
‘* are Crawled, they will have return “User DisplayName’s – Blog rather than just “Blog".
'******************************************************************************************

If properties.Web.Site.HostName = “mysites.portal.contoso.com” Then
If properties.Web.WebTemplateId = “9” Then

Try
Dim spResource As SPUserResource = properties.Web.TitleResource
Dim sWebUrl As String = properties.ServerRelativeUrl
Dim sUserDisplayName As String = properties.UserDisplayName

properties.Web.Title = sUserDisplayName + “‘s – Blog”
properties.Web.AllowUnsafeUpdates = True
properties.Web.Update()

Catch ex As Exception
‘Throw a message in the ULS Logging
Microsoft.Office.Server.Diagnostics.PortalLog.LogString(“Exception Occurred Ascii.SP.ER.MySiteBranding: {0} || {1}”, ex.Message, ex.StackTrace)
End Try
End If
End If

‘Update Blog MasterPage
targetWeb.MasterUrl = rootWeb.MasterUrl
targetWeb.CustomMasterUrl = rootWeb.CustomMasterUrl
targetWeb.SiteLogoUrl = rootWeb.SiteLogoUrl
targetWeb.AlternateCssUrl = rootWeb.AlternateCssUrl
targetWeb.Update()

End Using

End Using

End Sub

End Class

Here is the Element.xml

<?xml version=”1.0″ encoding=”utf-8″?>
<Elements xmlns=”http://schemas.microsoft.com/sharepoint/”&gt;
<Receivers >
<Receiver>
<Name>MySiteWebProvisioningWebProvisioned</Name>
<Type>WebProvisioned</Type>
<Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
<Class>Ascii.SP.ER.MySiteBranding.MySiteWebProvisioning</Class>
<SequenceNumber>10002</SequenceNumber>
</Receiver>
</Receivers>
</Elements>

In my Feature Stapler, I associated it with the MySite Template.  The Elements.xml for this is displayed below:

Elements.xml

<Elements xmlns=”http://schemas.microsoft.com/sharepoint/”&gt;
<FeatureSiteTemplateAssociation Id=”c4c9b0b4-c604-4ec0-8355-3136fd02411b” TemplateName=”SPSPERS#2″ />
</Elements>

Happy SharePointing!

Posted February 2, 2016 by Bismarck in SharePoint 2013, SharePoint 2016

How To Import New Managed Metadata Termsets   Leave a comment

Another method of getting your Termsets into the Managed Metadata Store is of course to just import them.  I have several pre-defined termsets that you can use.

Step 1 – From the Managed Metadata Store in SharePoint Central Administration, I created a “Global Term Properties” Group.  This will be where I create termsets to be used by everything in the entire farm.

Weekday_Termset_1

Step 2 – Upload your defined terms saved a Microsoft Excel Workbook or Comma Delimited File (.csv)

Weekday_Termset_2

Step 3 – Review your Imported terms

Weekday_Termset_3

To show you how I created these Excel files, I have several below that you can download, experiment with, or just use.

Bismarck!

Posted June 26, 2015 by Bismarck in SharePoint 2013

How To Add the Schools of the World as a Metadata Termset   Leave a comment

This took quite some time to gather and place into a Microsoft Excel worksheet but I persevered through the tedious effort to build a TermSet of what I call the “Schools of the World”.  This PowerShell script will populate a “Schools” termset with all of the known (as of today) Colleges and Universities on planet Earth.

To run, execute PowerShell as an Administrator or the SharePoint Setup Account. Navigate to the folder where the Script and .CSV file reside and type

.\SP-ImportTermSet.ps1 http://mysites.portal.contoso.com SchoolsTermSet.csv

This will add a “Schools” termset under the “People” Term Group.

Note: if “Schools” has not already been provisioned, your will need to run the script twice.  First to provision the termset, and second to populate it with the terms.

Download the SchoolsTermSet and rename it to SchoolsTermSet.csv, then copy the PowerShell Termset Installer below as SP-ImportTermSet.ps1.

PowerShell Script: SP-ImportTermSet.ps1

#*******************************************************************************
#*        Author: Paul D. Fox
#*          Date: 05/08/2014
#*   Description: PowerShell Script to Import TermSets into the Managed Metadata
#*                Term Store from a .CSV of specified terms.
#*
#* Modifications: MM/DD/YYYY – Description
#*
#*     Execution: Modify the parameters below to coincide with your Farm
#*                Credentials, Managed Metadata Service Name, and Term Group
#*      Description. To run this script create open the SharePoint
#*                Management Shell and Execute the following from the directory
#*                where the .csv resides.
#*
#* To Execute, type the following:
#* .\SP-ImportTermSet.ps1 “http://mysites.portal.contoso.com&#8221; “SchoolsTermSet.csv”
#*
#*******************************************************************************
param(
[string]$siteUrl,
[string]$inputFile)

[string]$termStoreName = “Managed Metadata Service Proxy”
[string]$termGroupName = “People”
[string]$termGroupDescription = “Term Store used to Extend User Profile Information”
[string]$termGroupMgr = “CONTOSO\SPFarmAdmin”
[string]$termGroupContributor = “CONTOSO\SPFarmAdmin”
[string]$termSetDescription = “Schools”
[string]$termSetOwner = “CONTOSO\SPFarmAdmin”
[string]$termSetStakeholder = “CONTOSO\SPFarmAdmin”

#Add the SharePoint PowerShell Snap-In
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#*******************************************************************************
#* Check if both params are passed, else show Syntax.
#*******************************************************************************

if ($siteUrl -eq “”)
{
“Syntax: S2-ImportTermSet , ”
exit;
}
if  (-not($siteurl.ToLower().StartsWith(“http`://”)))
{
“Invalid Web Application Url”
“Syntax: Build-CbMySites ”
exit;
}
if ($siteurl.EndsWith(“/”))
{
$siteurl = $siteurl.Substring(0,$baseUrl.Length -1)
}
#*******************************************************************************
# [string]$siteUrl = $(Read-Host -prompt “Site Collection URL”),
# [string]$termStoreName = $(Read-Host -prompt “Term Store Name”),
# [string]$termGroupName = $(Read-Host -prompt “Term Group Name”),
# [string]$termSetName = $(Read-Host -prompt “Term Set Name”),
# [string]$inputFile = $(Read-Host -prompt “Input File (including full path)”))
#*******************************************************************************

[Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint.Taxonomy”) > $null

function Get-SpTermGroup
{
$termGroup = $termStore.Groups[$termGroupName];
if ($termGroup -ne $null)
{
return $termGroup
}
else
{
$termGroup = $termStore.CreateGroup($termGroupName)
$termGroup.Description = $termGroupDescription
$termStore.CommitAll()
$termGroup.AddGroupManager($termGroupMgr)
$termGroup.AddContributor($termGroupContributor)
$termStore.CommitAll()
return $termGroup
}
}

function Get-SpTermSet([string]$termSetName)
{
$termSet = $termGroup.TermSets[$termSetName];
if ($termSet -ne $null)
{
return $termSet
}
else
{
$termSet = $termGroup.CreateTermSet($termSetName)
$termSet.Description = $termSetDescription
$termSet.Owner = $termSetOwner
$termStore.CommitAll()
$termSet.AddStakeholder = $termSetStakeholder
$termStore.CommitAll()
return $termSet
}
}

function Add-SpTerm([string]$termName, $parentTerm)
{
try
{
if ($parentTerm -eq $null)
{
$term = $termSet.CreateTerm($termName, 1033);
}
else
{
$term = $parentTerm.CreateTerm($termName, 1033);
}
if ($term -eq $null)
{
Write-Host “Term $termName could not be created” -ForegroundColor Red
}
else
{
$term.IsAvailableForTagging = $available ;
write-host “Term $termName has been created”
if ($synonyms.Count -gt 0)
{
foreach ($synonym in $synonyms)
{

$term.CreateLabel($synonym,1033, $false);
write-host ”    Synonym $synonym has been created”
}
}
$termSet.TermStore.CommitAll();
}
}
catch { }
return $term
}

function Get-SpTerm([string]$termName, $parentTerm)
{
if ($parentTerm -ne $null)
{
$term = $parentTerm.Terms[$termName];
}
else
{
$term = $termSet.Terms[$termName];
}
if ($term -eq $null)
{
$term = Add-SpTerm $termName $parentTerm
}
return $term
}

function Import-SPTermStoreGroupTerms
{
$isValid = $true;
$message = “”;
if ($siteUrl.Length -eq 0)
{
$message = “`nPlease provide a site URL”;
$isValid = $false;
}
if ($termStoreName.Length -eq 0)
{
$message += “`nPlease provide a Term Store Name”;
$isValid = $false;
}
if ($termGroupName.Length -eq 0)
{
$message += “`nPlease provide a Term Store Group Name”;
$isValid = $false;
}
if ($inputFile.Length -eq 0)
{
$message += “`nPlease provide an input file”;
$isValid = $false;
}
else
{
$csv = Import-csv -path $inputFile
if ($csv -ne $null)
{
[string]$termSetName =  $csv[0].”Term Set Name”;
if ([string]::IsNullOrEmpty($termSetName))
{
$message += “`nPlease provide a Term Set Name”;
$isValid = $false;
}
}
else
{
return “Argument supplied for input file was invalid.”;
}
}
if ($isValid -eq $false)
{
write-host “`n`nERROR OCCURRED`n`t$message`n`n”
write-host “NAME`n`tImport-SPTermStoreGroupTerms`n”
write-host “SYNOPSIS`n`tConsumes a CSV file containing a listing of term names and creates them if needed in the specified term set.`n”
write-host “SYNTAX`n`tImport-SPTermStoreGroupTerms siteUrl termStoreName termGroupName termSetName inputFile`n”
write-host “EXAMPLES`n`n Import-SPTermStoreGroupTerms “”http://sp2010″&#8221; “”Managed Metadata Service”” “”Enterprise Metadata”” “”Business Units”” “”C:\Users\Me\Desktop\input.csv””`n”
write-host “SAMPLE INPUT FILE`n`tTerm`n`tSample Term 1`n`tSample Term 2`n`tSample Term 3`n”
return;
}
try
{
$ErrorActionPreference = “Stop”;
try
{
$taxSession = Get-SPTaxonomySession -Site $siteUrl;
try
{
$termStore = $taxSession.TermStores[$termStoreName];
if ($termStore -ne $null)
{
try
{
$termGroup = Get-SpTermGroup
if ($termGroup -ne $null)
{
try
{
$termSet = Get-SpTermSet $termSetName
if ($termSet -ne $null)
{

foreach($line in $csv)
{
$available = $false
$synonymList= $null
$synonyms = $null
[string]$termName1 = $line.”Level 1 Term”;
[string]$termName2 = $line.”Level 2 Term”;
[string]$termName3 = $line.”Level 3 Term”;
[string]$termName4 = $line.”Level 4 Term”;
[string]$termName5 = $line.”Level 5 Term”;
[string]$termName6 = $line.”Level 6 Term”;
[string]$termName7 = $line.”Level 7 Term”;
[string]$switch = $line.”Available for Tagging”;
[string]$synonymList = $line.”Synonyms”;
if (-not ([string]::IsNullOrEmpty($synonymList)))
{
$synonyms = $synonymList.Split(“|”);
}
if ($switch.ToLower() -eq “true”)
{
$available = $true
}
#Get Level 1 Term
$term = Get-SpTerm $termName1

if (-not ([string]::IsNullOrEmpty($termName2)))
{
$term = Get-SpTerm $termName2 $term
if (-not ([string]::IsNullOrEmpty($termName3)) )
{
$term = Get-SpTerm $termName3 $term
if (-not ([string]::IsNullOrEmpty($termName4)) )
{
$term = Get-SpTerm $termName4 $term
if (-not (![string]::IsNullOrEmpty($termName5)) )
{
$term = Get-SpTerm $termName5 $term
if (-not (![string]::IsNullOrEmpty($termName6)) )
{
$term = Get-SpTerm $termName6 $term
if (-not (![string]::IsNullOrEmpty($termName7)))
{
$term = Get-SpTerm $termName3 $term
}
else
{
return “Error:  Term Name Left Blank”;
}
}
}
}
}
}
}
}
else
{
return “Termset $termSetName does not exist in the term store group $termGroupName”;
}
}
catch
{
“Unable to acquire the termset $termSetName from the term group $termGroupName”
}
}
else
{
return “Term store group $termGroupName does not exist in the term store $termStoreName”;
}
}
catch
{
“Unable to acquire term store group $termGroupName from $termStoreName”
}
}
else
{
return “Term store $termStoreName does not exist”;
}
}
catch
{
“Unable to acquire term store for $termStoreName”
}
}
catch
{
“Unable to acquire session for the site $siteUrl”
}
}
catch { }
finally
{
$ErrorActionPreference = “Continue”;
}
}
Import-SPTermStoreGroupTerms
Remove-Variable * -Scope Local -ErrorAction SilentlyContinue

Bismarck!

Posted June 24, 2015 by Bismarck in SharePoint 2013

Tagged with