Loading...

Follow I like SharePoint on Feedspot

Continue with Google
Continue with Facebook
or

Valid

In SharePoint you can add elements at different places. If you like to do, it is not necessary to change the masterpage or customize it. You can simply use user custom actions. This is useful if you like to create additional header elements like language switch buttons or a footer which shall be displayed on all sites. In this article i would like to show this kind of SharePoint branding and how to get it working with an example of a footer.

First we have a look at what we try to create:

Screen of how it could look like with a footer

This footer should provide two links, for example it could be a link for imprint and one for data privacy. But it can be anything, like social buttons or a copyright notice.

Create the footer Javascript file

Create a javascript file. Upload this file together with jquery in the site collection where you would like to add your footer. Let’s have a look at the javascript:

$(document).ready(function () {
	//load the footer contents
	var footerHtml = "<div id='mycustomFooter' >";
		footerHtml = footerHtml + "<div >";
			footerHtml = footerHtml + "<ul>";
				footerHtml = footerHtml + "<li><a href='/sites/pages/page1.appx'>My Page 1</a></li>";
				footerHtml = footerHtml + "<li><a href='/sites/pages/page2.appx'>My Page 2</a></li>"
			footerHtml = footerHtml + "</ul>";
		footerHtml = footerHtml + "</div>";
	footerHtml = footerHtml + "</div>";

	$('#s4-workspace').append(footerHtml);
});

As you can see we first define how our html area of the footer will look like. At the end we append this html area at the end of the div of #s4-workspace. Just save the javascript in my case the filename ist mycustomFooter.js and i upload it to the SharePoint Site Collection into Site Assets. There i also uploaded the current version of jquery which we need in our javascript.

Create User Custom Action with Powershell

Next we have to tell SharePoint that it should inject this script into the site. In this scenario we will use Powershell in order to create the user custom action. There are also client side scripts to get it working. If you are working in an Office 365 tenant you should look at this post. We will create a user custom action which adds a scriptlink to add our Javascript Script. Let’s see what we do in the Powershell script:

 
If ((Get-PsSnapinWhere-Object { $_.Name -eq "Microsoft.SharePoint.PowerShell" }) -eq $null)
{
    Write-Host "Loading SP PowerShell cmdlets..."
    Add-PsSnapin Microsoft.SharePoint.PowerShellOut-Null
}

$url = "https://yoursharepointserver/sites/yoursitecollection"
 
try {
    $site = Get-SPSite $url
    $ucaFooter = $site.UserCustomActions? { $_.Title -eq "mycustomFooter.js" }Select -First 1
 
    if ($ucaFooter -eq $null) {
        $ucaFooter = $site.UserCustomActions.Add()
    }
 
    $ucaFooter.Title = "mycustomFooter.js"
    $ucaFooter.Location = "ScriptLink"
    $ucaFooter.ScriptSrc = "~sitecollection/SiteAssets/mycustomFooter.js"
    $ucaFooter.Sequence = 100
    $ucaFooter.Update()

    $ucaJquery = $site.UserCustomActions? { $_.Title -eq "jquery-3.4.1.min.js" }Select -First 1
 
    if ($ucaJquery -eq $null) {
        $ucaJquery = $site.UserCustomActions.Add()
    }
 
    $ucaJquery.Title = "jquery-3.4.1.min.js"
    $ucaJquery.Location = "ScriptLink"
    $ucaJquery.ScriptSrc = "~sitecollection/SiteAssets/jquery-3.4.1.min.js"
    $ucaJquery.Sequence = 100
    $ucaJquery.Update()
 
 
} catch {
    Write-Host "Error" -ForegroundColor Red
    Write-Host $_.Exception.Message -ForegroundColor Red
    Write-Host $_.Exception.StackTrace -ForegroundColor Red
}

In this script we simple add two user customs. One for mycustomFooter.js and one for jquery. The location is important: Scriptlink – this adds the javascript to the scriptlink area. Well after run this script, we are done.

The advantage of this method should be clear: There is no need to change your masterpage.

  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

The SharePoint Search by default has some refiner if you create a SharePoint Search center. But in the default settings there is no filter or refiner for the site title. Mostly the user know the site name but not always the url. But we would like to have a shiny SharePoint Search Site.

Prepare SharePoint Search Schema

So here i would like to show an easy way to provide the Site Title of a SharePoint Site Collection as Refiner. The information is already in your search schema. The site title is stored in “ows_SiteName”. So i created a new managed property “SiteTitle” and mapped the crawled property to “ows_SiteName”. After that run a full crawl.

Add Refiner

After the full crawl you can use your managed property. Edit your search result page and go to the refiner webpart properties. In this settings you can choose your managed property “SiteTitle” as refiner.

Settings for Refiner in SharePoint

Save your site and let’s see how it looks like:

SharePoint Search Result with Refiner for Site Title

That’s one way. If you prefer to use RefinableStrings follow this post by Nik Charlebois.

  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Creating a script in order to copy and rename files and folders from one location to another i was happy to find some easy Powershell Scripts. So I’d like to share some important and interesting ones.

If you like to copy a folder from location A to location B you can simply use this script:

 Copy-Item -Recurse -LiteralPath $SourceFolder  -Destination $TargetFolder

This one will just copy your complete folder. Cause of “-Recurse” it will also copy the complete subfolders and subitems.

Rename Files

If you like to rename Files inside a Folder and all subfolder you can use this script. The special thing is, that there is a filterscript. This filter is used in order to find all files which containing special characters. All other files we don’t care. After we get all files with special characters we use Rename-item with same expression.

 Get-ChildItem -Recurse -path $baseTarget -FileWhere-object -FilterScript { $_.Name -match '[^.^a-zA-Z0-9_]' }Rename-Item -NewName { $(Convert-Umlaut -Text $_.Name) -replace '[^.^a-zA-Z0-9_]','_' 

In this Script there is another special: In the rename-item area, we use a function for the filename and replace “Umlaute” like “ä ö ü” and replace them with ae, oe, ue.

Rename Folders

If you wish to rename Folders it’s almost the same but, we have to define first -Directory and we also make a filterscript.

 Get-ChildItem -path $baseTarget -Directory -RecurseWhere-object -FilterScript { $_.Name -match '[^a-zA-Z0-9_]' }Rename-Item -NewName { $(Convert-Umlaut -Text $_.Name) -replace '[^a-zA-Z0-9_]','_' }  
Why Filterscript?

I am using the filter script for one reason. If i don’t use it, and the foldername does not contain special characters then the script tries to rename the folder anyway. But then it tries to change the Name from “Example1” to “Example1” and of course it will throw an error which tells you that the source and destination cannot be the same. And of course there is no need to change the foldername if it does not contain a special character.

Hope it helps you.

  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Did you ever used the search query in Powershell? Powershell can send a search query against the SharePoint Search. It is great in order to automate some tasks, in which you need data from various site collection which can be collected by simply using the search. So how would it look like?

Example
    $SearchQuery = "ManagedProperty:Value"
    $clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
    $keywordQuery = New-Object Microsoft.SharePoint.Client.Search.Query.KeywordQuery($clientContext)
    $keywordQuery.QueryText = $SearchQuery 
    $keywordQuery.RowLimit = 500;
    $searchExecutor = New-Object Microsoft.SharePoint.Client.Search.Query.SearchExecutor($clientContext)
    $results = $searchExecutor.ExecuteQuery($keywordQuery) 
    
    $clientContext.ExecuteQuery()
    $results.Value[0].ResultRows
3 things you should pay attention

So that is easy. But you should pay attention to three things if you use a Powershell script in order to make a search query.

#1 Choose the right user which executes the script
It is really important. The search results are based on the permission on the user who sends the request. So if you have a employee who would search for “secret documents” he would find less than if your SharePoint Search Account or Admin Account would do the same query. So if you automate tasks with it keep in mind that the user who runs the query should have correct permissions. Not too much but not too less.

#2 RowLimit
If you get always 50 search results it might be hint, that there is a limit. And that’s it. By default the search results row limit is set to 50 elements. You can raise it up to 500.

#3 Check your results
You should always check your results. Is the numbers of result rows correct and is the content of your search results correct? Could it be that there is an information which should not be due to permissions which are not correctly set? Better check twice

Resources

If you need a complete step by step instruction, here is a good how to guide

  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

There are a lot of post how to create a custom display template for SharePoint Search. Today i would like to show a how you can add the default hover panel with the preview of document content inside. So this post intends not to customize the hover panel but rather include the default hover panel with preview of your documents in your custom search display template.

Prequerisites

First of all i assume you created your custom display template. If not, let me share here some posts which lead you through the process of creating one.

[1] Microsoft Blog

[2] How To Create Custom Display Templates For SharePoint Search by Prashant Bansal

[3] 10 Tips and Tricks by Elios Struyf

Well now we have our custom Display template.

In order to get also the cool hover panel with preview in our search results respective in our custom display template we simply have to check a few things.

Activating default hover panel with Preview of documents

If you copied the item_default.html file you will realize that there is a hover panel inside. But this hover panel does not show the preview. If you compare the item_default.html file with item_word.html file you see some differences.

#1 Difference: Managed Property Mapping

Item_Default.html

<mso:ManagedPropertyMapping msdt:dt=”string”>’Title’:’Title’,’Path’:’Path’,’Description’:’Description’,’EditorOWSUSER’:’EditorOWSUSER’,’LastModifiedTime’:’LastModifiedTime’,’CollapsingStatus’:’CollapsingStatus’,’DocId’:’DocId’,’HitHighlightedSummary’:’HitHighlightedSummary’,’HitHighlightedProperties’:’HitHighlightedProperties’,’FileExtension’:’FileExtension’,’ViewsLifeTime’:’ViewsLifeTime’,’ParentLink’:’ParentLink’,’FileType’:’FileType’,’IsContainer’:’IsContainer’,’SecondaryFileExtension’:’SecondaryFileExtension’,’DisplayAuthor’:’DisplayAuthor'</mso:ManagedPropertyMapping>

Item_Word.html

<mso:ManagedPropertyMapping msdt:dt=”string”>’Title’:’Title’,’Path’:’Path’,’Description’:’Description’,’EditorOWSUSER’:’EditorOWSUSER’,’LastModifiedTime’:’LastModifiedTime’,’CollapsingStatus’:’CollapsingStatus’,’DocId’:’DocId’,’HitHighlightedSummary’:’HitHighlightedSummary’,’HitHighlightedProperties’:’HitHighlightedProperties’,’FileExtension’:’FileExtension’,’ViewsLifeTime’:’ViewsLifeTime’,’ParentLink’:’ParentLink’,’FileType’:’FileType’,’IsContainer’:’IsContainer’,’SecondaryFileExtension’:’SecondaryFileExtension’,’DisplayAuthor’:’DisplayAuthor’,‘ServerRedirectedURL’:’ServerRedirectedURL’,’SectionNames’:’SectionNames’,’SectionIndexes’:’SectionIndexes’,’ServerRedirectedEmbedURL’:’ServerRedirectedEmbedURL’,’ServerRedirectedPreviewURL’:’ServerRedirectedPreviewURL’</mso:ManagedPropertyMapping>

Here we see the differences. There properties mapped which are used for the hover panel preview.

#2 Difference: Connected

Item_Default.html

var hoverId = id + Srch.U.Ids.hover;
var hoverUrl = “~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_Default_HoverPanel.js”;

Item_Word.html

var hoverId = id + Srch.U.Ids.hover;
var hoverUrl = “~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_Word_HoverPanel.js”;

This difference is also important. In this Hover Panel the preview is integrated.

Conclusion

So if you like to get the standard hover panel inside your custom search display template, you should add the necessary managed property mappings and of course switch to the right hover panel.

So here is the display template html basic which shows the preview inside the hover panel



<html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882">
<head>
<title>Word Item</title>

<!--[if gte mso 9]><xml>
<mso:customdocumentproperties>
<mso:templatehidden msdt:dt="string">0</mso:templatehidden>
<mso:masterpagedescription msdt:dt="string">Displays a result tailored for a Microsoft Word document.</mso:masterpagedescription>
<mso:contenttypeid msdt:dt="string">0x0101002039C03B61C64EC4A04F5361F385106603</mso:contenttypeid>
<mso:targetcontroltype msdt:dt="string">;#SearchResults;#</mso:targetcontroltype>
<mso:htmldesignassociated msdt:dt="string">1</mso:htmldesignassociated>
<mso:managedpropertymapping msdt:dt="string">'Title':'Title','Path':'Path','Description':'Description','EditorOWSUSER':'EditorOWSUSER','LastModifiedTime':'LastModifiedTime','CollapsingStatus':'CollapsingStatus','DocId':'DocId','HitHighlightedSummary':'HitHighlightedSummary','HitHighlightedProperties':'HitHighlightedProperties','FileExtension':'FileExtension','ViewsLifeTime':'ViewsLifeTime','ParentLink':'ParentLink','FileType':'FileType','IsContainer':'IsContainer','SecondaryFileExtension':'SecondaryFileExtension','DisplayAuthor':'DisplayAuthor','ServerRedirectedURL':'ServerRedirectedURL','SectionNames':'SectionNames','SectionIndexes':'SectionIndexes','ServerRedirectedEmbedURL':'ServerRedirectedEmbedURL','ServerRedirectedPreviewURL':'ServerRedirectedPreviewURL'</mso:managedpropertymapping>
</mso:customdocumentproperties>
</xml>< ![endif]-->
</head>
<body>
<div id="Item_Word">
<!--#_
if(!$isNull(ctx.CurrentItem) &amp;&amp; !$isNull(ctx.ClientControl)){
var id = ctx.ClientControl.get_nextUniqueId();
var itemId = id + Srch.U.Ids.item;
var hoverId = id + Srch.U.Ids.hover;
var hoverUrl = "~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_Word_HoverPanel.js";
$setResultItem(itemId, ctx.CurrentItem);
ctx.CurrentItem.csr_Icon = Srch.U.getIconUrlByFileExtension(ctx.CurrentItem);
ctx.CurrentItem.csr_OpenApp = "word";
ctx.currentItem_ShowHoverPanelCallback = Srch.U.getShowHoverPanelCallback(itemId, hoverId, hoverUrl);
ctx.currentItem_HideHoverPanelCallback = Srch.U.getHideHoverPanelCallback();
_#-->
<div id="_#= $htmlEncode(itemId) =#_" name="Item" data-displaytemplate="WordItem" class="ms-srch-item" onmouseover="_#= ctx.currentItem_ShowHoverPanelCallback =#_" onmouseout="_#= ctx.currentItem_HideHoverPanelCallback =#_">
_#=ctx.RenderBody(ctx)=#_
<div id="_#= $htmlEncode(hoverId) =#_" class="ms-srch-hover-outerContainer"></div>
</div>
<!--#_
}
_#-->
</div>
</body>
</html>


Now your search results should display the preview like this:

  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Recently a customer’s SharePoint Farm throws an exception when using the search. The reason was a degraded search index partition cause the drive of the server was full. The error which the user gets:

“Search has encountered a problem that prevents results from being returned. …”

Diagnose

In Central Administration on the Search Service Topology Site you see this small warning icon below Index column:

Further investigation can be done with Powershell. Run this command:

$ssa = Get-SPServiceApplication -Name “Search Service Application”
Get-SPEnterpriseSearchStatus -SearchApplication $ssa -Detailed -Text

After that you’ll get the infos:

Name      : IndexComponent1
State     : Degraded
State     : List of degraded cells: Cell:IndexComponent1-SP9c29b725497bI.0.0;
Partition : 0
Host      : Servername

Name      : Cell:IndexComponent1-SP9c29b725497bI.0.0
State     : Degraded
State     : (Secondary index cell)
Primary   : False
Partition : 0

Name  : Partition:0
State : Degraded
State :
Degraded cells: Cell:IndexComponent1-SP9c29b725497bI.0.0;

Solution: Reset Search Index

In order to get search working again, you should reset the Search Index and perform a Full Crawl of all Content Sources again. This somehow might be not the best option if you have a lots of content sources and many indexed files. But i still didn’t found a different solution. So if you have an idea i would appreciate if you share it.

Some more details on this can be found in this blog post.

By the way this can happen due to low storage as well as network related problems.

  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Microsoft released the new Version of SharePoint 2019 and within there are several new features like the SMTP Authentication. This feature now allows to connect to SMTP Servers directly from SharePoint. There is no need to use an SMTP relay just configure the Outgoing Mailsettings via Central Administration or Powershell.

Configuration via User Interface

Simple and easy. But before SharePoint needs an application credential key. Therefore we need a Powershell script:

$key = ConvertTo-SecureString -AsPlainText -Force “myapplicationcredentialkey”
Set-SPApplicationCredentialKey $key

This has to be done on each SharePoint Server in the farm.

Configuration via Powershell

Open the Powershell App and use this script:

$CentralAdmin = Get-SPWebApplication -IncludeCentralAdministration? { $_.IsAdministrationWebApplication -eq $true }
$SmtpServer = “smtp.Server.com”
$SmtpServerPort = 587
$FromAddress = “user@example.com”
$ReplyToAddress = “replyto@example.com”
$Credentials = Get-Credential

Set-SPWebApplication -Identity $CentralAdmin -SMTPServer $SmtpServer -SMTPServerPort $SmtpServerPort -OutgoingEmailAddress $FromAddress -ReplyToEmailAddress $ReplyToAddress -SMTPCredentials $Credentials

After that you can use the outgoing email function.

Resources

https://docs.microsoft.com/de-de/SharePoint/administration/outgoing-email-configuration

  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

In one of our SharePoint Farms we recognized, that suddenly some SharePoint Workflows shows a message “Failed to start”. We tried to manually restart them, but the error comes again. After investigation of error logs and workflows in SharePoint Designer we realized that only some of the workflows didn’t work. Those who uses conditions and special tasks belonged to the workflows not working anymore.

One of the error messages was:

“System.CodeDom.CodeBinaryOperatorExpression is not marked as authorized in the application configuration file”

So we tried to republish the workflow. But SharePoint Designer throwed an similiar message, that activities or conditions could not be found. But only at workflows which didn’t run. We could republish working workflows.

After some more research, we found a really good article, which helped in this situation:

“After installing .NET security patches to address CVE-2018-8421, SharePoint workflows stop working (KB 4457916/4457035 and others)”

So the reason was an security patch. After adding the entries into the web.config of SharePoint the Workflows worked again.

  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Microsoft announced the possibility to create realtime live events in Microsoft Stream. You can setup your live-video as on-demand video and as live events. You can start the live event from Microsoft 365 – that means from Office Groups as well as from Yammer and Microsoft Stream itself. So this a seamless integration in your Office 365 world.

Start a live event

Watch the video to get to know how to start a live event.

Introducing Live Events in Microsoft Stream - YouTube

Further features

It’s possible to comment this video for example in Yammer. The comments can be seen by the producer of the live event. If you use more than one camera, you can switch easily the camera while you’re in a live production of the event. You can see how many viewer currently watching your video

See more details at the techcommunity site.

  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Separate tags by commas
To access this feature, please upgrade your account.
Start your free month
Free Preview