Monthly Archives: April 2011

SharePoint 2010 KeywordQuery and Anonymous Users

I enabled anonymous access in my site to test out a search web part I’ve been developing and to no great surprise, it didn’t quite work.  Anonymous access is pretty much always a challenge for me.

In this case, the initial search wasn’t running for some reason.  I should say that it was running but it was not returning any results.  I’m using the KeywordQuery for that initial display.

I did a quick search and this blog post by “sowmyancs” came up fairly quickly: “SharePoint 2010 Search: not showing any results for anonymous users?”  That blog entry describes the problem from an out of the box keyword search perspective but the behavior was similar to mine – it worked for authenticated users and for anonymous users, but anonymous users got no results. 

I followed the instructions and bang!  It solved my issue.  I’m not sure what side effects this will have and they may prove to be a problem, but the short term result is helpful.

Click on through the blog:

image

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

SharePoint 2010 KeywordQuery and the HiddenConstraints Property

I’ve been doing a bit of work with the KeywordQuery object in SharePoint 2010 and making use of the HiddenConstraints property.

I didn’t find any immediately helpful information on the that property, so I thought I’d quickly jot down how I’ve been using it.

As far as I can tell, this is an automatic constraint added to the query so that you can sort of park it there and not worry about it.  As such, it’s just another keyword (or set of keywords) and modifiers that you can type in to the UI when you do a keyword search.  Here’s an example:

keywordQuery.HiddenConstraints = "scope:\"Industry\"";

You can add additional constraints with a space delimiter.

keywordQuery.HiddenConstraints = "scope:\"Industry\" defense";

The above is saying in English, “run a keyword query looking for “defense” and furthermore, use the “Industry” scope.

Here’s another way of looking at it:

image

I’ve been using it to provide a context-dependent automatic scope on a custom web part.  When the user clicks on a tab and clicks a search button, the tab dictates a particular search scope.  It’s working well so far.

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

Example: XSLT Creating HTML Href’s

I’ve been doing a bit of XSL stuff lately and thought I’d put together a sample for my future reference and that may be of value to all of us XSLT-ers making a living in the internets.

Consider the following XML:

<FdcSearchTabsCollection Count="2">
  <SearchTab Label="Industry" SortOrder=”00” Label=”Industries” SearchConstraints="contenttype:Industry" TabID="831b2a74-98c4-4453-8061-86e2fdb22c63"/>
  <SearchTab Label="Practices" SortOrder=”01” Label=”Practices” SearchConstraints="contenttype:PracticeGroups" TabID="678e206b-6996-421f-9765-b0558fe1a9c0"/>
</FdcSearchTabsCollection>

The following XSL snippet will generate a sorted list of hrefs tabs:

<xsl:template match="FdcSearchTabsCollection" xml:space="preserve">
   
    <!– The "all" tab –>
    <a href="javascript:ViewTab(‘All’)">View all</a>
   
    <!– Each individual tab –>
    <!– Iterate through all the Tabs and display the correct  links. –>
    <xsl:for-each select="SearchTab">
      <xsl:sort select="@SortOrder"/>

      …
      <a href="javascript:ViewTab(‘{@TabID}’)"><xsl:value-of select="@Label"/></a>
    </xsl:for-each>

    <br/> 
   

   </xsl:template>

Here’s what it looks like in SharePoint:

SNAGHTML78aa2cb

 

 

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

SharePoint MVP Chat on Wed 04/20

I’ll be participating in one of the period MVP chats next week, 04/20.  Here’s Microsoft’s write-up and link to the registration:

Do you have tough technical questions regarding SharePoint for which you’re seeking answers? Do you want to tap into the deep knowledge of the talented Microsoft Most Valuable Professionals? The SharePoint MVPs are the same people you see in the technical community as authors, speakers, user group leaders and answerers in the MSDN and TechNet forums. By popular demand, we have brought these experts together as a collective group to answer your questions live. So please join us and bring on the questions! This chat will cover WSS 3.0, MOSS, SharePoint Foundation 2010 and the SharePoint Server 2010. Topics include setup and administration, design, development and general question.
Please join us on Wednesday April 20th at 9am PDT/noon EST to chat with MVPs from around the world. Learn more and add these chats to your calendar by visiting the MSDN event page http://msdn.microsoft.com/en-us/events/aa497438.aspx

I joined in one of these last year and it was a real blast.  It’s just a crazy kind of open question/answer extravaganza. 

Here are some of the (currently) scheduled SharePoint MVP participants:

Cornelius van Dyk
Dan Attis
Daniel Wessels
David Martos
Ivan Sanders
Jeremy Thake
John Ross
Kris Wagner
Mike Oryszak
Randy Drisgill
Woody  Windischman
Zlatan Dzinic

That’s a wide spectrum of interests and specialties.  I think this will be a fun time and good use of your lunch hour (or any hour during the day Smile )

Sign here here (http://msdn.microsoft.com/en-us/events/aa497438.aspx).

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

One Reason for “One or more field types are not installed properly”

I was making a small tweak yesterday to a web part that does a CAML query against a list.  I made the change, deployed it and got hit with an error:

An unexpected error has occurred in the Three Day Outlook Weather Forecast WebPart. Please contact the system administrator. One or more field types are not installed properly. Go to the list settings page to delete these fields.

I was facing another oddball issue earlier so I didn’t immediately connect my CAML query with the error that SharePoint was reporting to me.  I did a quick bing search and and found this helpful blog post by Sandeep Nahta  (http://snahta.blogspot.com/2009/01/one-or-more-field-types-are-not.html).

Here is the bad query:

query.Query += "<Where><And><Neq><FieldRef Name=’Abbr’/><Value Type=’Text’>SFNY</Value><FieldRef Name=’Abbr’/><Value Type=’Text’>SFIS</Value></Neq></And></Where>";

Here it is fixed:

query.Query += "<Where><And><Neq><FieldRef Name=’Abbr’/><Value Type=’Text’>SFNY</Value></Neq><Neq><FieldRef Name=’Abbr’/><Value Type=’Text’>SFIS</Value></Neq></And></Where>";

So, the moral of the story is: make sure your CAML is correct or you may get an oddball error.

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

</end>

Quick Fix For “There has been an error while loading the form”

I’m testing a custom SharePoint Designer 2010 activity this fine Sunday afternoon and I was unexpectedly hitting a “Critical Error” when trying to launch the workflow:

There has been an error while loading the form.

Click Start Over to load a new copy of the form.  If this error persists, contact the support team for the Web Site.

Click Close to exit this message.

Show error details

Of course, if you click the “Show error details” button all it does is show you a correlation ID:

image

In my case, this turned out to be an Alternate Access Mappings problem.  I looked at the log file in the 14 hive and saw that InfoPath was complaining about an AAM issue (since I was hitting localhost instead of the server name).  I changed my URL and that solved it.

It does to show that with all the linkings of the various bits now in SP 2010, the thing you naturally this is a problem (SharePoint Designer workflow in my case) is actually totally unrelated to the core problem.

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

</end>