Trying to Modify the Code

Oct 22, 2010 at 7:46 PM

Hi,

your solution is real great and thanks alot for this.

I am trying to modify this code to include the search with in all the Libraries of a site and its subsites. I tried to modify the search editor to incude all the lists of the current site and subsites it displays all the lists of the site and its subsites. But when i try to search it gives an exception sync exception and inner exception saying that the list doesn't exists or may have been deleted by some other user.

can you please put some light for me which function should i change to include the search for all the lists of current site and its subsites.

Coordinator
Oct 24, 2010 at 5:11 AM

 

I'm assuming that your running this on a development server on which you have visual studio installed? If you start the build process with F5 (so that it builds and deploys the web part) then visual studio should automatically attach itself to the web server process - in which case, when the code throws an exception such as the one you describe, it should take you to the point in the code where the error is. From there you should be able to see the problem.

It might also help you if I give you a quick description of some aspects of the way the web part works:

First of all, if you look at the search part of the code (in SearchButton_Click) you should see that the actual fulltextsqlquery has a CONTAINS clause. This limits the search results to those sites whose URL includes the current site's URL. That means that the search itself will already return results from the current site and all of its sub-sites. So in other words, you shouldn't need to touch that part.

Where you will need to look at is the line "SPList aList = getListCurrentUser(libGuid);" in SearchButton_Click. The documentation says "returns a list from the *current* site if the user has permission to access it". The hashtable AMLibsSel contains the Guids for the lists - but the above line assumes that the list is on the current site, which for you it won't be. So that's probably where it's falling over. You'll need to find an alternative way of getting the SPList object for it to work.

You might change what is stored in AMLibsSel (the library key might be the same, but the stored object could be something that includes the Guid and the site URL, for example). Or you might want to store a separate hashtable to get the site URL from the Guid and use that. That might be a "cleaner" way of doing it (i.e. it wouldn't impact the rest of the code).

Good luck - and don't forget to post what you find and share your new found knowledge with everyone.

Cheers

Ron

Coordinator
Oct 25, 2010 at 1:45 AM

Hi again,

 

Now that I look at it again, that routine (getListCurrentUser) should just return null if your GUID is from a different site. So that shouldn't be the cause either. I'm afraid we'll need more detail about where the exception is being thrown. If it really is the search itself then the exception will be thrown at the line that reads

ResultTableCollection rtc = myq.Execute();

So put a breakpoint there, run to that point then step over it (F10). If the error occurs there, post your query string and we'll have a look. Otherwise, we'll need more info to be able to help.

Ron