In my daily rss readings I ran across this little nugget of information that hasn't burned me yet, but something good for anyone working with the SharePoint Search API to tuck away for later.

Long story short, make sure that the query text that you pass to the FullTextSqlQuery is less than 4096 characters otherwise your going to run into some errors.

Last night we had our monthly meeting of the Philly Office Geeks User Group and I think it was another successful meeting.  Dave Mann, who runs the group, was on a much deserved vacation so I filled in for him and moderated the meeting as well as gave the presentation.  Also the company I work for Perficient, sponsored the meeting.  Many thanks to them for supplying the food and beverages!


I've noticed that SharePoint Search is one of those topics that is overly hyped/talked about, but not many people understand it.  I have been in the fortunate position to get down to some of the nitty gritty with SharePoint Search and wanted to pass along that knowledge to everyone and help them understand it as well.  My presentation went over the basic concepts of search (content sources, scopes, etc.) and also dived head first into using the SharePoint Search engine in your webparts/apps by using the web services and the API.


This was my first "draft" of this presentation so everyone got a trial run of it.  I noticed a few area's that I could have elaborated on more or explained a bit better, namely content sources and scopes.  I plan on refining this presentation and presenting it again at the next Philly.Net Code Camp 2008.3 which is coming up in October.


Thanks to everyone that attended and I hope you understand SharePoint search a bit better now and how you can leverage it in your applications/webparts.


Code and Slides :

...also up on Philly Office Geeks Site

I ran across a really helpful link the other day for a common SharePoint development task...deleting all items from a SharePoint list.  You can read the full article here, as well as the full code over on MSDN Code Gallery

As the posting states, the advantage of the method below is that you pass an XML string batch to the site to have the items deleted, essentially making only 1 connection the server.  Iterating over each list item and deleting them individually would essentially make calls to the server on every delete.

For the sake of this blog posting/historical purposes, I've included the code below to help explain it.


   1:  StringBuilder sbDelete = new StringBuilder();
   3:  sbDelete.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Batch>");
   5:  string command = "<Method><SetList Scope=\"Request\">" + spList.ID + 
   6:  "</SetList><SetVar Name=\"ID\">{0}</SetVar><SetVar Name=\"Cmd\">Delete</SetVar></Method>";
   8:  foreach (SPListItem item in spList.Items)
   9:  {
  10:      sbDelete.Append(string.Format(command, item.ID.ToString()));
  11:  }
  13:  sbDelete.Append("</Batch>");
  15:  spSite.RootWeb.ProcessBatchData(sbDelete.ToString());


What I really like about this code is its simplicity, but also provides the ability to do some add conditions inside the foreach loop, and test for certain values.  This way, you could delete say, all items with a date of 1/1/2007. 

A few things to note after reading the posting and its comments.

All items that get deleted from this method go into the Recycle Bin which is important to remember.  To COMPLETELY get rid of the items, use the code above then also call the delete method of the Recycle Bin from your SPWeb object ( mySpWeb.RecycleBin.DeleteAll(); )

Another option, which is a tad less flexible, but does essentially the same, is to switch a list to data view mode, which turns it into an excel like spreadsheet where you can highlight all the rows and delete them that way.


Needless to say, the options above are better then just iterating through all the items in the list and calling delete.

Posted in: Sharepoint  Tags: ,

What the hell is the "SharePoint Ninja Toolkit" you ask?  It is going to be where I plan to release the countless small little utility apps/features that I've written over my SharePoint development experiences.  Almost every project I've worked on I end up with small little apps or chunks of code that end up sitting around that I reference from time to time.  I figured, I might as well polish these up a tad and release them out there for others to enjoy.  Hopefully it will save someone the headache of having to do it themselves, or if anything, serve as a learning tool.

Check it out over at CodePlex. (Right now its unpublished, but by the end of the week i'll have at least 1 or 2 small utilities up there to start it out.)

Today I ran into a bit of an issue in a SharePoint server farm environment where I added a web part to a page, but for the life of me I couldn't delete it.  I clicked the 'X' button, I tried to edit properties, I tried to delete from the edit pull down menu, but nada!  I tried from the load balanced URL and from the Index Server but no dice.  I did a quick google search and hit this helpful link,

Basically by adding "Contents=1" as a query string variable to any page, you'll go directly to the web part maintenance page for that page.

Ex. http://{site url}/pagewithproblemwebpart.aspx?contents=1 will take you to the maintenance page.


Update 7/7/2008

The url above will actually redirect you to the following url. 

Ex. http://{site url}/_layouts/1033/spcontnt.aspx?&url=pagewithproblemwebpart.aspx


Between the two url's I provided you should be able to deal with problem web parts and get back to a working page with little downtime.

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2017 Tony Testa's World