March 11, 2014

SharePoint: Web Part Title URL with Refinement QueryString parameter

Task

I wanted to point SharePoint Web Part Title URL to a search results page with prepopulated refinement values. It didn’t work, as in Web Part settings, whenever I tried to input a valid URL with refinement parameter, I got error.

Example URL with refinement QueryString that didn’t work:

/Pages/MyPage.aspx?r=owstaxIdMyCategory:"a6c4a141-1b0e-4a2e-a7f7-2479251e3505"

 

Solution

You need to encode the colon (:) with %3A, so Web Part Title URL field becomes

/Pages/MyPage.aspx?r=owstaxIdMyCategory%3A"a6c4a141-1b0e-4a2e-a7f7-2479251e3505".

January 22, 2014

TFS: Delete workspace of another user

Task

I changed my account on Team Foundation Server Online and had multiple workspaces bound to my old account, so when trying to create new workspace I could do so as there was already a workspace created for my old account.

Solution

You need to use TF command on Visual Studio command prompt to remove the old workspace. Syntax is:

tf workspace /delete "WORKSPACENAME;PREVIOUSUSERACCOUNT”

as this was TFS Online, it was Microsoft Account, so in my case actual command was

tf workspace /delete "MIWORKSPACE;juss.palo@sulava.com"

January 10, 2014

SharePoint: Hide list rows with CSR

Problem

I needed to hide certain rows on a list view on SharePoint 2013, namely all items that contained either _ or @ characters. I couldn’t use normal list view filtering as there is no “NOT CONTAINS” clause in CAML.

Solution a.k.a dirty hack

I’m not too happy with the outcome, but I just couldn’t figure out how to override item rendering and only render item row if Title of the item didn’t contain the characters in question. What I ended up doing was using Client Side Rendering together with jQuery and postRenderHandler to remove the TR rows from DOM.

I didn’t want to customize the XSLT of the XsltListViewWebPart and use a simple XSL:IF to filter out the items because as soon as I customized the XSLT in SharePoint Designer, the UI of the list reverted to SP2010 look and feel. I really wanted to maintain the SP2013 look.

Oh, and the code, put it into a file, and reference it from JSLink on your list view web part:

var MiPortalViews = MiPortalViews || {};

(function () {
  var MiPortalOverrides = {};
  MiPortalOverrides.Templates = {};

  MiPortalOverrides.OnPostRender = [];
  MiPortalOverrides.OnPostRender.push(postRenderHandler);

  SPClientTemplates.TemplateManager.RegisterTemplateOverrides(MiPortalOverrides);
})();

function postRenderHandler()
{
    j("a:contains(_):contains(@)").closest("tr").remove(); 
}

January 8, 2014

SharePoint: Manually upgrade Service Application database

Task

After upgrading from SharePoint 2010 to SharePoint 2013, I didn’t need to upgrade all possible Service Applications, but Managed Metadata was one I needed to upgrade. Following TechNet instructions and trying to create new Managed Metadata Service Application using the old SP2010 database never completer, the PowerShell command just stuck and never finished – also the MM Service Application was stuck in Stopped state and couldn’t be started with $mms.Provision().

So, I created fresh Managed Metadata SA, and restored the old database over the new one, after which the Database Upgrade Status page showed that the database would need to be upgraded, how to do that? First guess was $db.Upgrade(), but that wasn’t it.

image

Solution

In order to upgrade the database, you need to provision it. So, in PowerShell do the following:

  1. Get a list of databases: Get-SPDatabase
  2. Get a hold of the database you want to upgrade: $db = Get-SPDatabase <GUID OF THE DATABASE FROM PREVIOUS STEP>
  3. Finally do the upgrade: $db.Provision()

All done!

December 13, 2013

SharePoint FBA LdapRoleProvider login issue

Problem

After configuring Active Directory Forms Based Authentication (FBA) towards your Claims enabled Web Application successfully, users still cannot log in, but get generic error: “The server could not sign you in. Make sure your user name and password are correct, and then try again.”

You can assign permissions to users normally, so People Picker on Central Admin site and the actual portal site do find FBA versions of user accounts.

Even if you set ULS logs to Verbose, there isn’t a single row mentioning any errors or even verbose details of the login process. You have double-and triple checked that everything is configured OK.

Only error that is logged, is into Windows Application log:

Log Name:      Application
Source:        Microsoft-SharePoint Products-SharePoint Foundation
Date:          13.12.2013 12:19:25
Event ID:      8306
Task Category: Claims Authentication
Level:         Error
Keywords:     
User:          SP\MyPortalAppPool
Computer:      spportal.sp.dev
Description:
An exception occurred when trying to issue security token: The security token username and password could not be validated..

image

Solution

The interweb was full of valid reasons why this error is occurring, but none of them mentioned the most self-evident reason for the error message: your username is incorrect! The picture above actually already includes a simple textual instructions for users so they know what they need to type into the username field.

When moving from traditional Windows authentication to FBA, you no longer can use DOMAIN\username or email address as username. Instead you must use the “User logon name” as defined in AD user properties.

image

 

Technorati Tags:

October 22, 2013

SharePoint search query using date range

Task

This is a quick one. Task was to search SharePoint items with specific date range, say, Created date being between (and including) 1/1/2013 and 12/31/2013. Every place on the internet this was asked, answer was to use queries like this:

Created>=1/1/2013 AND Created<=12/31/2013. 

Well, it works, but why not use the range operator?


Solution

Use the range operator .. (two periods) like this:

Created=1/1/2013..12/31/2013

Note that range operator is inclusive, so you'll get items matching start and end dates of the range.

October 8, 2013

List of SharePoint TimeZoneID values

Task

I needed to create new SharePoint Online site collection using PowerShell, and for that a TimeZoneId was required. Below is the list of valid integers required by the TimeZoneId parameter of the New-SPOSite command.

Values


<option value="39">(UTC-12:00) International Date Line West</option>
<option value="95">(UTC-11:00) Coordinated Universal Time-11</option>
<option value="15">(UTC-10:00) Hawaii</option>
<option value="14">(UTC-09:00) Alaska</option>
<option value="78">(UTC-08:00) Baja California</option>
<option value="13">(UTC-08:00) Pacific Time (US and Canada)</option>
<option value="38">(UTC-07:00) Arizona</option>
<option value="77">(UTC-07:00) Chihuahua, La Paz, Mazatlan</option>
<option value="12">(UTC-07:00) Mountain Time (US and Canada)</option>
<option value="55">(UTC-06:00) Central America</option>
<option value="11">(UTC-06:00) Central Time (US and Canada)</option>
<option value="37">(UTC-06:00) Guadalajara, Mexico City, Monterrey</option>
<option value="36">(UTC-06:00) Saskatchewan</option>
<option value="35">(UTC-05:00) Bogota, Lima, Quito</option>
<option value="10">(UTC-05:00) Eastern Time (US and Canada)</option>
<option value="34">(UTC-05:00) Indiana (East)</option>
<option value="88">(UTC-04:30) Caracas</option>
<option value="91">(UTC-04:00) Asuncion</option>
<option value="9">(UTC-04:00) Atlantic Time (Canada)</option>
<option value="81">(UTC-04:00) Cuiaba</option>
<option value="33">(UTC-04:00) Georgetown, La Paz, Manaus, San Juan</option>
<option value="65">(UTC-04:00) Santiago</option>
<option value="28">(UTC-03:30) Newfoundland</option>
<option value="8">(UTC-03:00) Brasilia</option>
<option value="85">(UTC-03:00) Buenos Aires</option>
<option value="32">(UTC-03:00) Cayenne, Fortaleza</option>
<option value="60">(UTC-03:00) Greenland</option>
<option value="90">(UTC-03:00) Montevideo</option>
<option value="103">(UTC-03:00) Salvador</option>
<option value="96">(UTC-02:00) Coordinated Universal Time-02</option>
<option value="30">(UTC-02:00) Mid-Atlantic</option>
<option value="29">(UTC-01:00) Azores</option>
<option value="53">(UTC-01:00) Cape Verde Is.</option>
<option value="86">(UTC) Casablanca</option>
<option value="93">(UTC) Coordinated Universal Time</option>
<option value="2">(UTC) Dublin, Edinburgh, Lisbon, London</option>
<option value="31">(UTC) Monrovia, Reykjavik</option>
<option value="4">(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna</option>
<option value="6">(UTC+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague</option>
<option value="3">(UTC+01:00) Brussels, Copenhagen, Madrid, Paris</option>
<option value="57">(UTC+01:00) Sarajevo, Skopje, Warsaw, Zagreb</option>
<option value="69">(UTC+01:00) West Central Africa</option>
<option value="83">(UTC+01:00) Windhoek</option>
<option value="79">(UTC+02:00) Amman</option>
<option value="5">(UTC+02:00) Athens, Bucharest, Istanbul</option>
<option value="80">(UTC+02:00) Beirut</option>
<option value="49">(UTC+02:00) Cairo</option>
<option value="98">(UTC+02:00) Damascus</option>
<option value="50">(UTC+02:00) Harare, Pretoria</option>
<option value="59">(UTC+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius</option>
<option value="101">(UTC+02:00) Istanbul</option>
<option value="27">(UTC+02:00) Jerusalem</option>
<option value="7">(UTC+02:00) Minsk (old)</option>
<option value="104">(UTC+02:00) E. Europe</option>
<option value="26">(UTC+03:00) Baghdad</option>
<option value="100">(UTC+03:00) Kaliningrad, Minsk</option>
<option value="74">(UTC+03:00) Kuwait, Riyadh</option>
<option value="56">(UTC+03:00) Nairobi</option>
<option value="25">(UTC+03:30) Tehran</option>
<option value="24">(UTC+04:00) Abu Dhabi, Muscat</option>
<option value="54">(UTC+04:00) Baku</option>
<option value="51">(UTC+04:00) Moscow, St. Petersburg, Volgograd</option>
<option value="89">(UTC+04:00) Port Louis</option>
<option value="82">(UTC+04:00) Tbilisi</option>
<option value="84">(UTC+04:00) Yerevan</option>
<option value="48">(UTC+04:30) Kabul</option>
<option value="87">(UTC+05:00) Islamabad, Karachi</option>
<option value="47">(UTC+05:00) Tashkent</option>
<option value="23">(UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi</option>
<option value="66">(UTC+05:30) Sri Jayawardenepura</option>
<option value="62">(UTC+05:45) Kathmandu</option>
<option value="71">(UTC+06:00) Astana</option>
<option value="102">(UTC+06:00) Dhaka</option>
<option value="58">(UTC+06:00) Ekaterinburg</option>
<option value="61">(UTC+06:30) Yangon (Rangoon)</option>
<option value="22">(UTC+07:00) Bangkok, Hanoi, Jakarta</option>
<option value="46">(UTC+07:00) Novosibirsk</option>
<option value="45">(UTC+08:00) Beijing, Chongqing, Hong Kong, Urumqi</option>
<option value="64">(UTC+08:00) Krasnoyarsk</option>
<option value="21">(UTC+08:00) Kuala Lumpur, Singapore</option>
<option value="73">(UTC+08:00) Perth</option>
<option value="75">(UTC+08:00) Taipei</option>
<option value="94">(UTC+08:00) Ulaanbaatar</option>
<option value="63">(UTC+09:00) Irkutsk</option>
<option value="20">(UTC+09:00) Osaka, Sapporo, Tokyo</option>
<option value="72">(UTC+09:00) Seoul</option>
<option value="19">(UTC+09:30) Adelaide</option>
<option value="44">(UTC+09:30) Darwin</option>
<option value="18">(UTC+10:00) Brisbane</option>
<option value="76">(UTC+10:00) Canberra, Melbourne, Sydney</option>
<option value="43">(UTC+10:00) Guam, Port Moresby</option>
<option value="42">(UTC+10:00) Hobart</option>
<option value="70">(UTC+10:00) Yakutsk</option>
<option value="41">(UTC+11:00) Solomon Is., New Caledonia</option>
<option value="68">(UTC+11:00) Vladivostok</option>
<option value="17">(UTC+12:00) Auckland, Wellington</option>
<option value="97">(UTC+12:00) Coordinated Universal Time+12</option>
<option value="40">(UTC+12:00) Fiji</option>
<option value="99">(UTC+12:00) Magadan</option>
<option value="92">(UTC+12:00) Petropavlovsk-Kamchatsky - Old</option>
<option value="67">(UTC+13:00) Nuku'alofa</option>
<option value="16">(UTC+13:00) Samoa</option>