Jonathan's IT Blog - Sharing Pointers

Saturday, June 15, 2013

Abstract, here is a trick to have the SharePoint Gantt view displayed scolled to today instead of the first day of the earliest task. Tested on SharePoint 2010 & SharePoint 2013. Here comes the trick and how it was found

SharePoint Gantt views are a great tool to visualy embrace a set of data\dates but they suffer from a few usability issue. First one is that Gantt view always center on the earliest date of the tasks displayed. This is often an issue if you display projects spanning multiple months or year as you don’t see today’s situation :

We decided to fix it. Our first stop was to take a look at SharePoint out of the box SPGantt.js file (SPGantt.debug.js for convenience), where best to find out what was possible. Searching for scroll brought up a few reference including this very promising one :

Next step was to manage to get an handle on this jsGridControl object. Fiddling through the DOM with Google Chrome (Elements and console tabs) we found out the *_ListViewWebPartJSGrid object had a nice jsgrid property that returns the object we need

And this object indeed have a ScrollGanttToDate function

If you use jQuery here is how to retrieve the object and scroll to today. Depending how\where you use it, you might want to make sure the object exists (if($("div [id$='_ListViewWebPartJSGrid']").length) ) before using the property jsGrid.

Friday, February 15, 2013

SharePoint 2010 introduced a great new feature that is used even more in SharePoint 2013, the tags. A major drawback of tags is that they are not clickable except in very specific scenario.

This post will explain some termstore\tagging concept before explaining how to make these tags clickable through a relatively small development. I’ll also talk very briefly about how to put in place a custom tag page as a target of these clickable tags.

Not all tags are born equal

The Managed Metadata Service Application aka as the termstore or to put it simply: Tags serves a lot of purpose from document classification to libraries navigation, search facet (even navigation and friendly URL in SharePoint 2013).

But it’s not so simple; Microsoft actually introduced two kind of tagging in SharePoint 2010:

Tags as properties of documents (actual tags thereafter) where the property values are picked from a list of possible values (part of the termstore with Managed Metadata typed column or whole termstore with Enterprise Keyword site column). Users can be allowed to submit values (folksonomy basis). The tag becomes a property of the document and actually describes it. The tag value is cached in the site collection itself in an hidden library (always at http://YOURSITE/Lists/TaxonomyHiddenList)

Tags as social actions (Social Tags), users can also in some places (at least enabled Document Libraries, Pages) social tags items. The tags values are picked from the termstore, however in this case the tags is not actually associated with the documents, it’s actually a property of the user. This action is not written down in the site collection content database at all but only lay in the User Profile Social database.

There is a major difference between these two types of tagging, one is an actual document property that can be used to classify and find the document, the other one is just a social action.

Microsoft decided to make social tags clickable, these links points to the tagpage. However to make sure we get confused, the tagpage actually just display the contents that has been “social tagged”. If a document has been classified with an actual tag, it will not appear in the tagpage. This is because the tagpage is actually a page to display the social actions of the users, the fact that it lay in the user profile web application leaves no doubt.

The issue is that social tags are not so useful for actual content management whereas actual tags are a must. Thus we realized we had no choice but to make these tags clickable and create our own tag page.

Click me ! Click me !

For the sake or maintainability\ease of use\compatibility and future evolutions we decided not to create a custom field type. Instead we focused our efforts on finding a way to make the out of the box field types clickable. There are actually only two of these, the SingleTaxonomyFieldType and MultipTaxoFieldType that are used for both Enterprise Keywords site columns and Managemed Metadata columns. We wanted to stick with supported customization so we made use of an extensibility option proposed with SharePoint 2010 (MSDN: Overview of XSLT List View Rendering System http://msdn.microsoft.com/en-us/library/ff604024(v=office.14).aspx ) that allow to change the rendering of an existing type, a real improvement from SharePoint 2007 by the way.

Beware of the priority setting above, that’s the key to make sure your customization is applied. You can quick-test that manually by placing the file and IISRESET.

With a bit more work to get the actual link we need, here is the result

Before

After

Cherry on the cake, there isn’t anything easier to deploy with a WSP, absolutely no code involved, just a folder mapping in Visual Studio.

Note that this works fine for list\libraries views when displaying multiple items, when displaying a single item (View Form), we used a small JavaScript to introduce the link, displaying only a single item means that performance is not an issue in this case.

A link, but where to ?

It’s great to have a link but links are supposed to point somewhere. As the default tag page only uses social tags it’s useless so we decided to create our own tag page.

The easiest solution we found to have both speed and security trimming was the search engine. Thus all the heavy-lifting is done by search while we can focus on displaying these results. This is possible because the search engine (tested on FAST 4 SharePoint, not Enterprise Search) has got a dedicated managed property to store tags that is queryable : Owsmetadatafacetinfo. This is the one used to render the tags facet on out of the box search pages.

So to test it, just run a search for :

Owsmetadatafacetinfo:ATAG

That’s it plain and simple and now you have the main ingredient to build your own tag page from scratch.

Conclusion

It first seemed like a major challenge at first to make tags as document properties useful (clickable + tag page) in the end it’s actually fairly simple when you know the tricks and the results is definitely worth it. If you wonder about SharePoint 2013, this development has not yet been tested in this configuration, though we know for sure that it will be needed as tags are still not clickable in SharePoint 2013.The good news SP2013 news is that there seems to be an out of the box tag page that actually work since it’s based on search. I will test it more extensively and let you know.

Tuesday, March 27, 2012

If you are currently running a pre December 2011 CU farm and have set up custom search center be careful before installing it. It seems like the maximum number of filters per refiner limits have been set to 250. We were previously using a value of 255 for a refiner. Thus installing the CU (SPF, SPF) broke our search center page with the following error:

Internal server error exception: System.ArgumentException: Max number of filters has to be between 0 and 250 at Microsoft.Office.Server.Search.WebControls.FilterCategory.set_MaxNumberOfFilters(Int32 value)

03/20/2012 16:16:07.85 w3wp.exe (0x1578) 0x1724 SharePoint Server Search Query g1j9 Exception Internal server error exception: System.ArgumentException: Max number of filters has to be between 0 and 250 at Microsoft.Office.Server.Search.WebControls.FilterCategory.set_MaxNumberOfFilters(Int32 value) at Microsoft.Office.Server.Search.WebControls.RefinementManager.ConfigureCategories() at Microsoft.Office.Server.Search.WebControls.RefinementManager.Initialize(Location location) at Microsoft.Office.Server.Search.WebControls.CoreResultsDatasourceView.CreateLocationList() at Microsoft.Office.Server.Search.WebControls.CoreResultsDatasourceView.SetPropertiesOnQdra() at Microsoft.Office.Server.Search.WebControls.SearchResultsBaseWebPart.EnsureWebpartReady() System.ArgumentException: Max number of filters has to be between 0 and 250 at Microsoft.Office.Server.Search.WebControls.FilterCategory.set_MaxNumberOfFilters(Int32 value) at Microsoft.Office.Server.Search.WebControls.RefinementManager.ConfigureCategories() at Microsoft.Office.Server.Search.WebControls.RefinementManager.Initialize(Location location) at Microsoft.Office.Server.Search.WebControls.CoreResultsDatasourceView.CreateLocationList() at Microsoft.Office.Server.Search.WebControls.CoreResultsDatasourceView.SetPropertiesOnQdra() at Microsoft.Office.Server.Search.WebControls.SearchResultsBaseWebPart.EnsureWebpartReady()

Saturday, July 23, 2011

Migrate user profiles from a different farm to your farm (MOSS 2007 to SPS 2010 IS supported)

Synchronize user profiles from a master a farm to a different farm (geographical replication or disaster recovery farm replication)

I have been playing with this tool a bit lately and here are a few things I noticed that might interest you. First of I would advise you to start with the official documentation at: http://technet.microsoft.com/en-us/library/cc663011.aspx . You will most likely only use the full and incremental commands.

1 -Full replication DOES NOT use any windows service

The Full synchronization ( Start-SPProfileServiceFullReplication )does not uses the Windows Service (aptly named “Replication Engine”) used by the incremental command (Start-SPProfileServiceIncrementalReplication). This is important as it means that the full sync is done with the account you launched the command line with WHEREAS the incremental sync is done with the “Replication Engine” service account. Knowing which account is running is important to know which account needs the permissions on the User Profile Service Applications.

2 - Local Admin permissions IS NOT needed for incremental sync

Running the incremental sync (i.e. the windows service) is possible with a non-local administrator account, but it needs:

Full permissions on the local folder where the replication engine is installed (C:\Program Files\Microsoft\SharePoint 2010 Administration Toolkit\Replication Engine)

Full permissions on the registry hive

HKLM:\Software\Microsoft\Replication Engine

HKLM:\SYSTEM\CurrentControlSet\services\eventlog

HKLM:\Software\Microsoft\EnterpriseCertificates

This is not based on any official documentation; I had to use Process Explorer to actually see what was preventing the Replication Engine from starting when running with a non-local admin account. The last two permissions might be optional but I added these anyway to be on the safe side. So far I haven’t seen any downside to this workaround.

3 - Full replication IS NOT needed before starting incremental sync

At least it is not always needed. If the User Profiles are already in sync because you did a fresh install and imported the profiles on source and destination with no other changes, you might skip the full sync and start with the incremental sync.

But if there is any difference between your two User Profiles SAs, start with the full as these differences will not be propagated.

In fact the incremental sync only propagates information that has been changed while it is running.

4 - Account changing option (credential parameter) behaves badly

The credential parameter of the Start-SPProfileServiceIncrementalReplication should be used to specify the windows service credential on the first run according to the documentation, well I don’t because it works erratically giving inconsistent results. Instead I set the windows service account itself. You can even do it in scripts.

5 - Social sync IS supported BUT

Social sync doesn’t included managed metadata (because it isn’t part of the User Profiles Service Application obviously) event though tagging is based on managed metadata. In fact tagging is stored in the User Profile DB as reference to the managed metadata entry.

Thus if you need to replicate tags you MUST replicate the managed metadata SA data as well.

6 - MySite URL CAN be replaced with the central administration Url

The documentation tells you to use the MySite Host Url for Source and destination but you can use the central administration URL as well.

In DRP (Disaster Recovery Plan) configuration it might be cumbersome to do so as URLs are shared on the source and destination farm. But the central administration URL being based on machine names is different on both farms.

Beware: this might depend on whether or not you User Profile SA is in the default Service Application Proxy group.

7 - Incremental sync is as fast as light

Yup it is seriously fast, so fast I thought my test protocol was broken when I started to test the replication :)

For large-scale environments, we recommend that you run the Web Analytics service application Reporting database on a server that is running SQL Server 2008 Enterprise Edition so that the Web Analytics service application can take advantage of table partitioning.

Sunday, February 06, 2011

Recently I was asked to add some element in the ribbon upper part just before the Site Actions Menu. Thus I needed to increase the height of the upper part of the ribbon to fit our content (blue part in the screenshot above).

Problem

After spending an insane amount of time on what seemed so simple, I managed to get it kinda working. I say “kinda” because no matter what I did I couldn’t get the ribbon to display correctly when it was opened.

I understood that it came from a FixRibbonAndWorkspaceDimensions() javascript function from init.js that just kept setting the height at 44px (ribbon collapsed) or 135px (ribbon opened) no matter what my CSS said. The culprit line is:

var baseRibbonHeight=RibbonIsMinimized() ? 44 : 135;

No need to tell you that after hearing Microsoft boast about their compliance with the latest Web Design best practices, I was expecting more than to find hard-coded height values in a JavaScript file…

Solution

Yet everything isn’t lost as the actual ribbonHeight is the aforementioned value plus a padding value

var ribbonHeight=baseRibbonHeight+g_wpadderHeight;

Thus if you want to increase the ribbon height, you just need to set the javascript variable g_wpadderHeight to the value you want to increment. You might do that in your masterpage as such :

<script type="text/javascript">

g_wpadderHeight = 30;

</script>

Something else to note, the WebPart adding part of the ribbon stopped displaying the “Add”, “Cancel” button after resizing the ribbon bar as they were out of the box. I solved this problem with a bit of css :

Thursday, January 20, 2011

As you probably all know, SharePoint 2010 allows site administrators to change the sites logos just like 2007 did. This is done on the “Title, description, and icon” page

The picture then appears in the top left of the site pages, just before the page title/breadcrumb

The trouble is that this doesn’t work on WebPart pages, no matter what you do; users will still see the default yellow icon.

Cause

WebPart pages use the TitleBarWebPart, this WebPart allows you to specify a title and logo for the page using the button in the ribbon bar

The problem here is that whatever you do, this Web Part always overrides your site logo setting. If you specify a page specific logo along with the title, it will use it. If you don’t specify a page specific logo, it will use the default SharePoint logo.

This overriding is done in javascript by the code below that you will find at the end of your web part page :

This javascript code is generated by the TitleBarWebPart, the “/_layouts/images/siteIcon.png” is replaced with the page specific logo if you set one. Thus this WebPart systematically overrides the site wide logo settings.
By the way you will notice that it doesn’t work under Chrome 8 because of a Javascript error.

Sunday, August 29, 2010

When analyzing data, I often find myself computing the percentile value. As I am a big fan of PowerPivot, I went with it lately to analyze some data and tried to get the 90th percentile of my series. So I chose to create a DAX measure and went looking for the PERCENTILE function only to discover that:

Accuracy of this measure

I am no statistician, the formula looked ok but I wanted more assurance about its accuracy. Thus I fixed a little test to compare the percentile computed with this DAX measure to regular Excel PERCENTILE.INC and PERCENTILE.EXC formula. I computed the 5,25,50,75,90,95 percentiles using these 3 means for 3 different kind of number series and then averaged the difference between those :

DiffINC is the difference in percentage between PERCENTILE.INC and the DAX measure. Same for DiffEXC.

As you can see, this DAX measure is giving results pretty close (less than 0,05% error) to the PERCENTILE.INC Excel formula. This is close enough for my needs anyway. Yet be careful, with smaller number series (less than 50 items), the error went up to reach values as high as 5% on some cases.

Percentile Explanation

By the way, for those unfamiliar with percentile, the Nth percentile is the value below which N% of the value fall. More details on Wikipedia.

Ok, so why it is useful you might ask, well it is common to analyze your data series without the extreme values that might indicate problem with your data source. An example is in the software performance testing field where you will usually consider the 90th or 95th values of the response time in order to know what the reasonable highest response time is without considering test aberrations or errors.

N.B: Some of you might have noticed the new addition to the title of this blog: Jonathan's IT blog – SharingPointers, tell me what you think in the comments !

Wednesday, May 05, 2010

I don’t know about you but tabbed navigation has become a must have for me in the past years. I mean who wants to open a different window for each and every web page.

Well my friends, it seems like Microsoft remembers too fondly those pre-tab browsing days and wants us to return to this prehistoric era. I am talking about the infamous Javascript links one can find in the SharePoint 2010 Central Administration – User Profile Service Application management page:

If you mouse over those links, you will see in the status bar that they are not actual links but instead Javascript calls:

If you add to that, the fact that the navigation is completely useless in this site, you have the recipe for a disastrous user experience as you can’t even open tab to compensate.

Having to work with the User Profile Service Application for a client I got fed up with the situation and decided to act. As javascript is the swiss knife of SharePointer, I wrote a script to replace those javascripts link with actual links so that I can open these links in tabs if needed :

If you want a more portable solution, I also put this code together as a Bookmarklet. Just drag and drop this link to your favorite bar. Thus whenever you are on the “Manage User Profile” page, just hit the link in the favorite bar to transform these nasty Javascript links into actual links.

Wednesday, April 21, 2010

Still using those plain olds SharePoint picture libraries? You know the libraries where a click on a thumbnail brings ups the DispaForm.aspx pages with details about the pics that none of your users care about. What about having your picture in your libraries shown this way instead :

Guess what, it’s as easy as ABC to enhance the way your picture libraries look like with very nice inpage popup.

A detailed walkthrough

Put the jQuery file and fancybox in someplace your user can access. For the sake of simplicity I am going to put these files in a document library for this walkthrough. In a real world scenario I am putting these files in the 12 using a WSP.

Create or open an existing document library

Create a JS folder (or not, I just like my stuff to be organized)

Push the jquery-1.4.2.min.js and fancybox folder in.

Now you can go to your Picture Library and Edit the page (screen grabbed from a French WSS Install)

The result might not yet be perfect; the two following notes shall set everything straight.

Notes 1,of missing GUI pics

The path to the pictures in the CSS might need to be modified for the pictures used by fancybox to work .So if you don’t see any Loading, Close, Prev, Next button, open the CSS in the document library (/documents/js/fancybox/jquery.fancybox-1.3.1.css)And replace

(src='/fancybox

with

(src='/documents/js/fancybox

Reload the Image Library in Internet Explorer and the pics shall be there.

Note 2, of using this with IE8:

This component seems to have trouble with IE8 and SharePoint. Without a strict XHTML doctype the picture frame are messed up as you can see on the right:

As adding an XHTML strict doctype was a no go, I tried to circumvent the problem by removing the frame and setting the white frame right. Here is the result:

Not as nice as what fancybox can do (lost the gradient border) but good enough for my purpose. To get this result you will need to do these modifications in the css file (the same on you modified in note 1):

Original & Instructions

Target

#fancybox-outer replace line

background: #FFF;

top:-10px !important;left:-10px !important;/*background: #FFF; */

#fancybox-inner replace line

top: 0;left: 0;

top: 0 !important;left: 0 !important;

.fancy-bg add line

display: none !important;

Add at the end of the file

.fancybox-ie {background-color:#fff;}

After saving the CSS and reloading the page you should be all set and ready to receive your end user congratulations :)

Of course, this is only a start. The next step would be to have the picture retrieved by a Content Query Web Part with the fancybox magic added. It would mean losing the option to download multiple picture and it would allow for an even better rendering.