Monday, March 28, 2011

SharePoint 2010 Content Query Web Part and Lookup Field Types

I know the topic of the Content Query Web Part (CQWP) and lookup fields has been covered pretty extensively, but I haven’t found an article anywhere that specifically makes this clear. When including a lookup field in the CommonViewFields property on the CQWP, you have a choice of specifying either “Lookup” or “MultiLookup” as the field type. I haven’t been able to find the latter option documented anywhere.

I’ll use the “Posts” list from the standard Blog site template as an example. It has a multi-value lookup column called “PostCategory” that references the “Categories” list. If you want to include this column in your query and expect to get back a complete dataset, you should set the CommonViewFields property to this:

<property name="CommonViewFields" type="string">PostCategory,MultiLookup</property>

If you don’t specify “MultiLookup” as the field type, any blog posts that have more than one category assigned will be returned in the dataset minus the category that has the lowest internal ID. So if you had some SharePoint-oriented categories like Architecture (ID=1), Administration (ID=2), and Development (ID=3) assigned to a post and you specified “Lookup” as your field type in the CQWP, you’d get back the following value for PostCategory in the returned XML:

PostCategory=”2;#Administration;#3;#Development”

Obviously this is bad. It seems odd that the query behaves this way. I would expect it to only return the first category, not everything else. To fix it, simply make sure you use “MultiLookup” instead. The returned value would then look like this:

PostCategory=”Architecture;#2;#Administration;#3;#Development”

Monday, March 14, 2011

Add global navigation to SharePoint 2010 Search Center

-- 11/29/2011 UPDATE --
Thanks to Falk and Furiant for the comments and troubleshooting. I've added an extra step to account for situations where users have read-only permissions. The corev4.css style sheet does not get loaded by default on minimal.master for these users and therefore does not style the navigation properly.

John Ross from SharePoint 911 has an article that describes why SP2010 search center templates use minimal.master for their master pages.

http://www.sharepoint911.com/blogs/john/archive/2010/05/12/sharepoint-search-center-uses-minimal-master-%E2%80%93-and-why-you-should-care-about-that.aspx

One of the most frequent requests I get from users that have (fairly) vanilla SP2010 deployments is to have the global navigation links included on search pages. The simplest way to do this is to make a copy of minimal.master and copy a div tag from v4.master. Here are the steps:

1. Open SharePoint Designer and connect to the root of the site collection where your search center lives. You’re going to need to access to the master page gallery.

2. Select “Master Pages” from the “Site Objects” pane on the left.

3. Make a copy of “minimal.master” and name it something nice like “search.master”. Open this new master page in split view.

4. Find the div tag that encloses the “PlaceHolderTitleBreadcrumb” content place holder control and paste in this markup (which I just copied out of v4.master) right above it.

<div class="s4-lp s4-toplinks">
    <asp:ContentPlaceHolder id="PlaceHolderTopNavBar" runat="server">
        <asp:ContentPlaceHolder id="PlaceHolderHorizontalNav" runat="server">
            <SharePoint:AspMenu
                ID="TopNavigationMenuV4"
                Runat="server"
                EnableViewState="false"
                DataSourceID="topSiteMap"
                AccessKey="<%$Resources:wss,navigation_accesskey%>"
                UseSimpleRendering="true"
                UseSeparateCss="false"
                Orientation="Horizontal"
                StaticDisplayLevels="2"
                MaximumDynamicDisplayLevels="1"
                SkipLinkText=""
                CssClass="s4-tn"/>
            <SharePoint:DelegateControl runat="server"
                ControlId="TopNavigationDataSource" Id="topNavigationDelegate">
                <Template_Controls>
                    <asp:SiteMapDataSource
                        ShowStartingNode="False"
                        SiteMapProvider="SPNavigationProvider"
                        id="topSiteMap"
                        runat="server"
                        StartingNodeUrl="sid:1002"/>
                </Template_Controls>
            </SharePoint:DelegateControl>
        </asp:ContentPlaceHolder>
    </asp:ContentPlaceHolder>
</div>

5. Find the CSS registration tag for minimalv4.css and paste in this tag right above it.

<SharePoint:CssRegistration Name="corev4.css" runat="server"/>

6. Save, check in, and publish the new master page.

7. Browse to your search center and change the site master page to use the one you just published. Your global navigation should now show up directly below the dark blue band that has the site logo and title.

Monday, October 25, 2010

Cannot create a Search Service Application

Recently I’ve been building out a few SP2010 farms manually using PowerShell so I can control the naming of certain elements like databases, app pools, etc. However, I ran into a situation where I needed to delete my search service (in two separate farms) and start over. At first, I couldn’t cleanly delete the service app. Both the web and PowerShell interfaces would just hang. Some pieces would get removed, and others would not. So this post helped me forcefully remove the service itself.

http://social.technet.microsoft.com/Forums/en-US/sharepoint2010setup/thread/88f7998f-4a88-4928-ba59-e76d7f6afcdc

This didn’t quite solve my problem though. When I would go to recreate the search service application, PowerShell would hang. I could see that just about everything was finished, but the service app was showing a status of “Error”. The trace logs didn’t help, so I began to dig around in the configuration database. Lo and behold, I found another row in the Objects table that had the same name as what I was trying to use for my recreated search service. I still don’t quite know how this happened… So I made sure I had the proper GUID for the orphaned item, and I used the stsadm –o deleteconfigurationobject command to remove the duplicate. Almost immediately my PowerShell command finished executing and all was well.

Both farms that had this issue had different orphaned items. On one farm, the object for the old service application needed to be deleted. On another farm, the objects for the crawl store and property store databases were the offenders.

Monday, July 26, 2010

Changing Publishing Page Layouts in SharePoint 2010

I had a problem this morning with trying to change the page layout for a publishing page in SP2010. I’m building my own content types and layouts for my company’s public-facing site, but I don’t have the time to build everything from scratch, so I’m using the out-of-the-box site definition. So to make things work the way I want them to, I am changing each site after creation to use my custom page layouts.

My problem is that after configuring the content types on the Pages library and changing the available page layouts for the site, I still could not change the layout on a page that was checked out to me and in edit mode. As it turns out, the Page Layout button on the ribbon is sensitive to the approval state of the available layouts. If there is no published version of a layout, it is technically unavailable. If none of the available layouts have been published, the button is disabled altogether.

This behavior is different than in SP2007, so it thoroughly frustrated me. Hopefully this will be of some help to others.

Thursday, July 22, 2010

SharePoint 2010 Exams: A Much Needed Improvement

I recently took and passed the four SP2010 beta exams. Having also taken the four older exams, I must say that Microsoft seems to have gotten it right this time.

These newer tests now break out skill measurements into a TS and PRO level for each track – administrator or developer. The PRO exams are fairly tough, and they are focused on scenarios that require you to review user requirements and plan/design a solution accordingly. The older tests broke WSS and MOSS out into their own exams for each track, and sadly, the questions (especially on the admin exams) were not designed well enough to be a good measurement.

Now all we need are exams that target the SharePoint Designer skill sets. Maybe Microsoft has something in the works for the next version…

Monday, November 16, 2009

Office 2010 Beta 2 Released to MSDN

Microsoft released a slew of Office 2010 beta products to MSDN today:
  • SharePoint Server 2010 Enterprise
  • SharePoint Server 2010 for Internet Enterprise
  • SharePoint Foundation Server 2010
  • FAST Search Server for SharePoint 2010
  • Search Server Express 2010
  • Office Web Applications 2010
  • Project Server 2010
  • Office Professional Plus 2010
  • SharePoint Designer 2010
  • Project Professional 2010
  • Visio Premium 2010
  • Business Contact Manager 2010

You have no idea how excited I am to finally get to play with this stuff. I've been using the Office client since the tech preview, but the only exposure I've had to the SharePoint beta has been at this year's SharePoint conference.

I hope to have lots of stuff to post coming up soon.

Thursday, September 17, 2009

The SPD Workflow History List Conundrum

I have this project that I’m working on that requires a lot of SPD workflows. Some of them are legitimate workflows, while others do quick actions like sending notifications or updating fields. At some point I realized that the default history list that SPD attaches to all workflows is going to get large pretty quickly.

So being a clever guy, I proceeded to write a small utility that would let me create new history lists and associate them with my workflows. I was okay with losing some of the history that would be displayed with the workflow statuses. Boy, what a bad idea…

I had three problems:
1. I couldn’t change the history list for workflow instances that were currently running. This was annoying, but I figured I’d get a chance to do it at some point when the workflows completed.
2. Any changes to the workflows in SPD changed the history list association back to the default one. Also annoying, but I could deal with it.
3. It completely prevented workflows from running. Yeah, I saved the best one for last.

I’ve given up on making this work. I’ll gladly accept any ideas that someone has on the matter (besides creating and packaging the workflows in Visual Studio). My internet searches have been in vain.