Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I need to query multiple document libraries and get a particular item's ID by matching the queried barcode value. I need the ID to update the metadata for that item using web services. All the document libraries are within the same site. What would be the best method to query for the item ID?

share|improve this question

3 Answers 3

up vote 6 down vote accepted

if you can use the same content type across multiple libraries, then you can create a Search Scope ( for the content type scoped @ site collection OR web application level) and user search.asmx or Object model for search API.

Search API once indexed queries really fast.

share|improve this answer
    
+1. I like this approach if possible: scalable and quick. Depending on what the OP is using for "Item ID", the OP might also need a new metadata property as well. –  Kit Menke Jan 3 '11 at 19:17
    
This is how I decided to implement the query, thanks for the help. It was easy to set up. –  sange Jan 4 '11 at 16:17

You can use a Data View Web Part with DataSourceMode="Crosslist" for this if you're looking for a "non-code" solution.

You can also use the Web Services themselves. Here's an example.

share|improve this answer

I think you can proceed by using SPSiteDataQuery. You can define its object and sets its properties to query libraries within a web and its child webs.

SPSiteDataQuery q = new SPSiteDataQuery();
q.Lists = "<Lists BaseType='1'/>";
q.Query = "<Where><Gt><FieldRef Name='ID' /><Value Type='Number'>0</Value></Gt></Where>";
q.Webs = "<Webs Scope='Recursive' />";
q.ViewFields = "<FieldRef Name='Title' /><FieldRef Name='ID' />"';
q.RowLimit = 10;

The Webs Property Scope='Recursive: This will search the web on which you execute the query and recurse through any child webs.

The Lists Property

This defines what type of document libraries and lists WSS will search for your items. You can specify the exact type of list, the base type or even specific lists. Examples of the Lists property are...

"" As above, this will search all lists which are based on a 'Document Library. This is useful if you only want to find documents. Other values for BaseType include...

0 - Generic list - This will search all lists and not document libraries. 1 - Document Library 3 - Discussion Forum 4 - Vote or Survey 5 - Issues list

You can find more info here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.