Showing posts with label sp2010. Show all posts
Showing posts with label sp2010. Show all posts

Monday, March 24, 2014

Caveats when using Summary Link Web Part in a Web Template

My scenario was that the Summary Link Web Part had been used on a site which was to be saved as a site template using the UI (Save site as template). Saving the template worked fine, but once you created a new site based on the template you got the infamous “List does not exist” error.

The reason for the error is that the SummaryLinkWebPart class inherits the DataFormWebPart class, which has a property called ListId. If the page which hosts the Summary Links Web Part is located in for example SitePages, then the id will point to that list. Once you save the template, this id will come along, and will of course not exist in the new site.

When it comes to the Summary Link Web Part it really don’t need a reference to a list, as it’s storing all the data inside the web part itself. To fix up the template site before saving it I wrote the following PowerShell script.

function FixWebpart($wpm) {
$count = $wpm.WebParts.Count-1
ForEach ($number in 1..$count )
{
$webpart = $wpm.WebParts[$number]
# Check if it's a summary link web part
if( $webpart.PsObject.TypeNames[0] -eq 'Microsoft.SharePoint.Publishing.WebControls.SummaryLinkWebPart' ) {
write-host "Fixing listid - " + $webpart.Title + " : " + $webpart.ID
# Set the id to a blank GUID
$webpart.ListId = [guid]::Parse("00000000-0000-0000-0000-000000000000")
$wpm.SaveChanges($webpart)
}
}
}

#Get a reference to the template site
$web = get-spweb https://intranet.contoso.com/sites/template
$list = $web.Lists.TryGetList("Site Pages")

foreach($item in $list.Items) {
$wpm = $web.GetLimitedWebPartManager($item.Url, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
FixWebpart($wpm)
}

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

Thursday, January 30, 2014

Keeping versions when upgrading documents from doc to docx in SharePoint

Today I got a support questions about why all the versions had been restarted on some documents in a library. It’s a QMS system, and keeping the version history is quite important for tracking.

The reason was that all the .doc files had been resaved as .docx, and then the old .doc files had been archived. This of course also messed up the unique document id’s by the document id provider, as new files had been saved, getting new id’s

If you edit properties on a document in SharePoint, you notice there is no way change the file extension.

image

However, if you open the library in Windows Explorer (via the ribbon), you can easily rename files from .doc to .docx.

The procedure to keep the history and document id would be:

  1. Open the .doc file in Word
  2. Save as .docx locally on your machine
  3. Rename the .doc file in Explorer to .docx (the folder you opened from SharePoint)
  4. Copy the locally saved .docx over to the Explorer folder

Monday, August 26, 2013

Accessing rank models in SharePoint 2010

I recently blogged about rank models in SharePoint 2013, and how you can use PowerShell to dump the existing rank model XML.
The commandlets to do so are more or less same as for SharePoint 2010, with one important difference, the RankingModelXML attribute is empty in 2010 (in most cases – more on that below).
$ssa = Get-SPEnterpriseSearchServiceApplication
Get-SPEnterpriseSearchRankingModel -SearchApplication $ssa | select RankingModelXML

RankingModelXML
---------------

Tuesday, March 26, 2013

An easy way to accomplish Home navigation links regardless of the path of your site collection

Most of my team mates deploy project solutions to http://project.server.local/ which means all links used in the solution can be prefixed with “/” and everything is related to the root path and works just fine.

I’m different and use http://server.local/sites/project. And of course all links going to root for me will go to http://server.local instead of http://server.local/sites/project.

The solution, at least for global nav in master pages etc. is to make use of the variable _spPageContextInfo, blogged by numerous people. This object holds several properties about the current page/item you are viewing (see _spPageContextInfo is your new best friend by Sahil Malik for a complete property listing).

The code below is a sample of a hyperlink on an image to the front page of the current site collection.



Wednesday, January 9, 2013

How to get thumbs to work with FS4SP when using Claims security in SharePoint

As stated in the Microsoft support article KB2554903 and KB2641517, document thumbnails with FS4SP and Claims based Authentication is not supported. There are also numerous threads on the Microsoft FS4SP forum about this.

I recently experiences this myself in a project and decided to fix it, because the fix is not really that hard. The issue is that when your browser calls http://server/_vti_bin/WACProxy.ashx it receives a 401 error due to it not handling claims.

A WSP for this solution can be downloaded from Codeplex. Note that the WSP will overwrite the existing WACProxy.ashx file, so you might want to create a copy of it first.

What I did was create a wrapper which calls the WACProxy running under elevated privileges instead, and switched out the existing WACProxy.ashx file with one pointing to my assembly.

using System.Web;
using Microsoft.SharePoint;

namespace mAdcOW.SharePoint
{
    public class WACProxy : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                var proxy = new Microsoft.Office.Server.Search.Extended.Query.Internal.UI.WACProxy();
                proxy.ProcessRequest(context);
            });

        }

        public bool IsReusable
        {
            get { return false; }
        }
    }
}


You might thing it’s very very bad running this in an elevated security context and thinking this might create a security hole. But it won’t. What the WACProxy does is sending back script which points to for example http://server/library/_layouts/MobilePageHandler.ashx. This call is then being executed by your browser using your logged in credentials. This means if you don’t have access to the document, you can’t generated a thumbnail for it either.

So we are merely running the call to generate the proper thumbnail URL in an elevated context to get around the claims error.

If you do not want to overwrite or replace the current WACProxy.ashx file, I have a webpart you can drop on the search page which will redirect calls to WACProxy.ashx to YourWACProxy.ash file instead. I will commit this to spsearchparts.codeplex.com at a later time.

Thursday, November 29, 2012

FS4SP Logger v4 release

I’ve been so lucky to get Alexey Kozhemiakin to include some improvements on the rank log of this tool.

In addition to better formatting of the rank log and splitting it into more detailed parts showing for example which managed properties you got a hit in, the tool now also provides the raw ranklog information as well.

v4 is available for download at http://fs4splogger.codeplex.com/

image

Thursday, June 28, 2012

How-to: Get individual items from a delimited field using FS4SP

Thought I’d share a small useful program I often use when indexing data into FAST Search for SharePoint. The issue is that you get data back from some system where the values are concatenated into one field. For example:

user1,user2,user3

But you want to treat each value as a separate one. In FS4SP you have to delimit the values with the unicode character U+2029. The task is simple; replace the exiting delimiter character with this special one.
If you get the data via BCS you might can change the SQL for a view to do this directly(haven’t tested), or you can employ a custom extensibility program. If doing the latter here’s the code:
using System;
using System.Xml;

namespace mAdcOW.MultiValue
{
  class Program
  {
    static int Main(string[] args)
    {
      try
      {
        XmlDocument doc = new XmlDocument();
        doc.Load(args[0]);
        foreach (XmlNode node in doc.SelectNodes("Document/CrawledProperty[@varType='31']"))
        {
          // here you can add replacement for other characters
          // as well besides comma
          node.InnerText = node.InnerText.Replace(',', '\u2029');
        }
        doc.Save(args[1]);

      }
      catch (Exception e)
      {
        Console.WriteLine("Failed: " + e.Message + "/" + e.StackTrace);
        return 1;
      }
      return 0;
    }
  }
}

Thursday, June 21, 2012

Why more people should blog (or My bad day hunting down an error with FS4SP)

Today has been one of those days where you feel you haven’t done anything productive, thinking you have tried all tricks in the book to fix some weird error to no avail.

And just now the solution came to me after spending some time with my family and letting my brain work it’s magic without my focus. And I’m just about 100% sure it will work when I test it tomorrow morning.

The short version

Always use mklink /J when moving a folder from within your FAST installation to another volume (and blog about any error you encounter for others to read).

Wednesday, June 13, 2012

Adding prefix logic to the ribbon search box

A common scenario when upgrading from SharePoint search to FAST Search for SharePoint is that you want to run the new search solution side by side with the old until you are comfortable switching.
image
One solution is having two search centers which targets the old and the new index. In my experience end-users find it cumbersome to navigate to the new search center in order to do testing because they want to use the search box in the ribbon as the entry point to the search center. The chosen solution for this post is to allow users to enter a prefix character in the search box to opt-in to use the new search engine.

Saturday, June 9, 2012

Using PowerShell in a .NET installer for a SharePoint App

powershell_2This is not a post about how to invoke PowerShell from within .NET or why you should do it. It is a post about second guessing why you write code the way you do.

At Puzzlepart we have created a time tracking application and we have an .exe installer to provision a site, and create all lists and content types needed. Some weeks ago we decided to have the installer deploy the WSP as well, and not only to post-deploy work.

Friday, March 9, 2012

How to: Make folder hits appear at the end of your search results

imagePaul Olenick tweeted me a question on how to get folder hits to appear at the end of the search results using FAST Search for SharePoint.

If we are talking about folders from file shares this is not too hard. If we refer to my post about Taking promotions/demotions one step further we can accomplish this by adding negative promotion using XRANK.

Friday, January 27, 2012

How to do Visual Best Bets for built-in SharePoint Search

Marcus Johansson did a post about the use of Best Bets this morning which inspired me to write this post. Read his post for more thoughts around the use of best bets.

Visual Best Bets is a feature of FAST Search for SharePoint which lets you point to a file with html content to be displayed above your search results. For example an image, silverlight or flash content can be used to graphically enhance what is linked to the keyword term. The Visual Web Part uses an iframe to accomplish this and loads up your content inside the iframe. This is useful as you can easily edit the html file at will.

But why go the extra mile for a separate file, or opt in for FS4SP for this feature? The Best Bet web part support the showing of keywords and keyword definitions. Keyword definitions are formatted as html. And a definition with html formatting is in effect a Visual Best Bet. (If you have more than one Visual Best Bet you want to assign to the keyword you would have to add them all to the same html for this to work.)

Tuesday, December 13, 2011

Returning Best Bets and Visual Best Bets with KeywordQuery and FAST Search for SharePoint

When using the Search Center the Best Bets or Visual Best Bets functionality works like a charm, but I have not been able to get it to work using the KeywordQuery class in SharePoint.

I had done some research previously on the matter after being contacted by Xavier Vanneste who blogged about this (http://blog.xvanneste.com/Lists/Billets/Post.aspx?ID=82), but was not able to figure it out at the time.

I’m currently writing sample code for my upcoming book on FS4SP and I had to figure this out. Time to bring out the tools!

One hour with the Visual Studio Reflector plugin and setting break-points internally in the SSA I finally figured it out. And in a way it was obvious.

Saturday, December 10, 2011

How to prevent an item from being indexed with FAST for SharePoint

Yes, it can be done!

[Update 2012-05-25: There is an even better hack to solve this issue as Kai wrote in a commen below this post. Check out Segei Sergeev answer in this TechNet thread.]

It’s Saturday, my kid has gone to sleep, and I finally have time to tell you guys the good news. Preventing an item from being index, or to paraphrase, to drop a document in the document processing pipeline is indeed possible!

You can already prevent items from being indexed by limiting SharePoint lists and libraries from being crawled with library settings and you can use crawl rules to exclude certain url patterns. But what I am talking about is preventing an item from being indexed based business rules in your organization and looking at the meta data of the item or inside the text of a file.

There are many scenarios for not wanting an item searchable. You might want to prevent indexing items in your organization which contains the super secret codename “wobba”, or items of a certain ContentType. When indexing file shares you don't have much meta data to go on at all for excluding items, so creating your own module with the proper rules might be the only way to go.

Monday, November 28, 2011

Creating a Secure Store Target application with access for all users

I am currently working on a SharePoint application which access users Exchange calendars via web services. In order to access the calendars we need to provide credentials and we use a service account which has access to all calendars.

Instead of storing the logon information of the service account in a list or web.config we want to store this in Secure Store which is ideal for storing credentials (big surprise there). We also want to create the Secure Store target application in code with an installer and not using Central Admin.

Sunday, November 20, 2011

Taking promotions/demotions one step further in FAST Search for SharePoint

promotionsI am not sure how many times I have read the documentation on promotions and demotions in Microsoft documentation, but I can say it is numerous.

And yet yesterday I discovered a valuable piece of nugget which I’m sure I will use a lot in the future.

Monday, October 17, 2011

A side-by-side approach for upgrading SharePoint search to FAST

search in capeMore and more businesses are upgrading their existing SharePoint 2010 search solutions to FAST Search for SharePoint. Doing so will most likely require scheduled downtime when you make the actual switch.

This can be avoided by cleverly upgrading your existing Search Service Application to a FAST Query SSA.

Want to learn more? Head over to my article at NothingButSharePoint.com for the details - http://pzl.no/qKacHz.

Tuesday, August 30, 2011

Adding the left navigation menu to web part pages in SharePoint 2010

I taught a SharePoint 2010 super-user class last week, and the students experienced like so many before them that the web part page layouts which come with SharePoint 2010 removes the left hand navigation menu (the quick launch).
image
This is nothing new and it has been blogged about since 2007. But on my 15 minute Google spree this morning I could not find a recipe which worked 100% with SharePoint 2010,  so I will give it a try myself, and hopefully this can help some others in the future. I’m sure someone else has a complete post on this which I missed, but at least I have leveled up myself in the use of SharePoint Designer and modifying existing layouts instead of creating custom ones :)

Thursday, August 11, 2011

Why you should use deep refiners with FAST for SharePoint

With FAST for SharePoint you have what is called deep refiners, compared to shallow refiners which the built-in search uses. The difference is that deep refiners guarantee an exact refiner count, and all possible refiner values for your search, while shallow will calculate the counts based on the first 50 hits (default setting which can be adjusted). In addition to deep refiners, FAST for SharePoint also supports shallow refiners.

The first image shows a query using FAST for SharePoint with deep refiners and the second image show the built-in SharePoint Search with shallow refiners.

image

image

With FAST for SharePoint deep refiners are stored in a separate data structure (mostly in memory), optimized for just that; returning the refiners. Think of it as a pre-calculated refiner tree, ready for the picking.

Shallow refiners on the other hand have to be manually constructed by the query server from the results returned. Returning a large result set, looking at the metadata and building the refiners, is both IO and CPU intensive, as it has to retrieve all metadata per item, and then build the refinement result based on that.

Of course, basing the refiners on 50 results is a speedy operation, but at the cost of the accuracy of deep refiners.

So, when you create a refiner with FAST for SharePoint, be sure to tick off the “Deep refiner” checkbox to take advantage of the refiner structure stored within the search index. You will not only get more accurate results, but in most cases they will also return even faster than shallow ones.

PS! There are cases when deep refiners will be slow, particularly if you have very many unique values within a refiner. Then again, if this is the case, you might want to re-think your search solution.

(Reference: http://technet.microsoft.com/en-us/library/gg193929.aspx)