Sunday, February 23, 2014

How to trigger a full re-index in SharePoint On-line

[Update 2019-09-02]
The script is no longer available due to request from Microsoft support - and there are good reasons for not doing this, even though there are good reasons for doing it as well :) Hit me up on twitter questions.

[Update 2015-01-05]
Latest version of the script can be found at https://github.com/wobba/SPO-Trigger-Reindex

In SharePoint Online you cannot trigger a full re-index of all your data as you can on-premises via the Content Sources on your Search Service Application.

And this might be something you would like to do, especially if you start mapping crawled properties to new managed properties. A full list of scenario’s which require a full re-index is available at TechNet.

The only option provided in SPO is to via the settings pages on a site or a list/library, trigger a re-index as outlined in the SPO documentation.

But fortunately this is not entirely true, as you via CSOM can manipulate a site’s property bag and set or change the value of vti_searchversion which is what triggers a re-index of this site. The same property applies to a list/library.

The below script uses the SharePoint Online Management cmdlets to iterate all the site collections, and SharePoint CSOM to iterate the sites within each site collection. For each site it will update vti_searchversion, which will trigger the site to be picked up for re-indexing on the next crawl cycle.

Wednesday, February 19, 2014

Remove auto-complete of external names when sharing in SharePoint Online - as well as sharing for that user

Note: As the title says, doing this will also remove sharing access for the user as the user is removed from the security groups in the site collection you are working.

Once you have shared a document or a site with an external user in SharePoint online, this person will then start to appear in the auto-complete dialog when you try to share something else.

image

In the image above you see my name Mikael Svenson appear twice. The first is my SPO account, the second is an external address I have shared a document with.

There might be cases where you don’t want this to appear, especially if you have stopped sharing something with that person. In order to remove the entry navigate over to https://tennant.sharepoint.com/_catalogs/users/simple.aspx, and click the user in question.

You should see a page similar to this:

image

Simply click Delete User from Site Collection and the user will no longer appear in the autocomplete box, nor will sites/documents in the site collection be accessible to the user from now on.

image

If you are directed to a user profile page instead of the User Info page, you have to first delete the user profile for the external user before removing him/her from the site collection user list.

Friday, February 14, 2014

Show announcements the old fashioned way replacing XSLT with JS Link

In my two previous posts (Sample on how to use Content Search to display an announcement list and Creating a custom display template for a content search web part) I showed how to use Content Search in order to bring filtered items back from an announcement list and formatting the result with custom html via display templates.

Topics covered in this post
  • XsltListView web part using JS Link
  • Referencing multiple .js files with JS Link
  • Custom date formatting
While using search is the new cool, there are other ways to accomplish this, which might be just as simple or even better.

In SharePoint 2010 you would have accomplished a custom view rendering using the XsltListView web part, and apply some fancy xslt to it. And this is the approach I’m going to show, except 2013 have added a new kid to the block to replace xslt, namely JS Link. JS Link is just a cryptic name for Display Templates for list views, and is really powerful in the way that you can use it to customize how a view or columns are displayed.

Let’s get to it!

First, edit the page where you want to show the announcements, click the Insert ribbon and click App Part. Then select the Announcement list (or any list other list).

image

Thursday, February 13, 2014

Restore UserDisp.aspx and UserEdit.aspx functionality after a User Profile Application has been removed

Before you provision a User Profile Application you may edit a users properties like e-mail and picture by clicking on your name and going to My Settings.

image

This takes you to _layouts/userdisp.aspx where you may click Edit Item to change your properties on the _layouts/useredit.aspx form.

Once you provision a User Profile Application you will not be sent to this page, but rather to your profile page instead.

I recently set up a demo environment where we did provision UPA, but decided we didn’t need it and thus removed it. This restores the link to My Settings, but once you click Edit Item you are presented with an empty form – major bummer!

image

As it turns out, when you provision a UPA it will set the fields in hidden site user info list to read only and hidden. An easy way to restore the form is to run the following via PowerShell which makes the fields visible and editable.

$web = Get-SPWeb http://intranet.contoso.com/
$names = "Title", "EMail", "MobilePhone", "Notes", "SipAddress", "Picture", "Department", "JobTitle"
foreach( $name in $names )
{
    $f = $web.SiteUserInfoList.Fields.GetFieldByInternalName($name);
    $f.Hidden = $false
    $f.ReadOnlyField = $false
    $f.Update()
}

Now you may yet again edit your properties.

image

Wednesday, February 12, 2014

Creating a custom display template for a content search web part

In my previous post (Sample on how to use Content Search to display an announcement list) I went over how to set up content search against an announcement list which had some additional fields added to it via a custom content type.
I will build on this sample and create a custom display template, which will add one more line to allow for the Body field of the announcement as well.
Topics covered in this post:
  • Create a custom display template
  • Render rich text fields properly
  • Render dates in a better fashion

Wednesday, February 5, 2014

Sample on how to use Content Search to display an announcement list

Figured I’d write a short sample on how you can use content search to display the last three announcements ordered by create time, filtering out the expired ones. I will also add parameters to limit fetching results from the announcement list on the particular web where we place the content search web part. This allows the site to be used as a web template with the logic still in place without hardcoding the path to the list.

The combination of content type and site/site collection is very powerful and especially useful if you create web templates.

Topics covered in this post:
  • Content Search Web Part
  • Query variables
  • Map date column to a managed property
  • Limit result to the current web, by content type and by date
  • Re-crawl of a list

Installing SharePoint 2010 with AutoSPInstaller on Windows Server 2012

The bad news;  this will not work out of the box. The good news; it’s not that hard to fix.
The issues are related to PowerShell v2 vs. v3 and .NET runtime v2 vs. v4. The catch 22 is that SharePoint commandlets requires PowerShell v2 with .NET runtime v2, while the WebAdministration commandslets in Windows Server 2012 requires PowerShell v3 and .NET runtime v4.