locked
Cross-site collection lookup RRS feed

  • Question

  • I have some different site collections where each site collection will have its own task list. I need to read the tasks of all the site collections and present them in a single separate site collection, where the admin will be able to see all the tasks and the visitor will be able to see the tasks assigned to him/her only.

     One of the solutions i considered was to create a REST data source, which is specified with the site collection name and task list name. This data source will be given to a data view web part. But the problem is i need to display tasks of all the site collections where one REST connection will be referred to one source only.

      How to handle this scenario. Please guide me. Many Thanks in Advance.

    NOTE: This scenario i am implementing in  sharepoint-2013 in office 365.

    Regards,

    Chaitanya.

     

    Friday, November 15, 2013 4:35 PM

Answers

  • Sorry, but I'm not sure what your question is.  If you use Search as the basis for the query you won't use CAML.  Also, it will automatically traverse all site collections because search by default includes all the site collections.  If you want to search only specific site collections you can do that by limiting the search results based on URL Path.

    Paul Stork SharePoint Server MVP
    Principal Architect: Blue Chip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

    • Proposed as answer by Amr FouadMVP Monday, November 18, 2013 8:21 PM
    • Marked as answer by Patrick_Liang Sunday, December 1, 2013 2:51 PM
    Monday, November 18, 2013 6:14 PM
  • Like what Paul was referring to the easiest way to use Search API and you have two options 

    • Keyword Query

    for keyword query you can set SourceID(ResultType) , romlimit,Querytext

    in the querytext you can filter using the search manged property for example if you want to search by Content Type it will be like the following

     KeywordQuery Kq = new KeywordQuery(SPContext.Current.Site);
                //fileter content type
                Kq.QueryText += "ContentType:ArticlePage";
                 //you can pass the selected managed properties to be returned in the search result table by setting the selectproperties string array 
                //properties to select
                foreach (string prop in selectProperties)
                {
                    Kq.SelectProperties.Add(prop);
                }
                
                    Kq.SortList.Add("ManagedPropertyUsedToSort","descending");
                    
                
                
                Kq.RowLimit = itemLimit;
               Kq.TrimDuplicates = trimduplicates;
               ResultTableCollection results= new SearchExecutor().ExecuteQuery(Kq);
               return results.Filter("TableType", KnownTableTypes.RelevantResults).FirstOrDefault<ResultTable>();
            

    • RESTful API

    execute GET request using $ajax call (useful in JavaScript client side scenarios

    http://server:port/_api/search/query?querytext='ContentType:ArticlePage'&rowlimit=10&selectproperties='Author,Write'

    for full RESTful API guide see below 

    http://blogs.msdn.com/b/nadeemis/archive/2012/08/24/sharepoint-2013-search-rest-api.aspx

     


    Hope that helps|Amr Fouad|MCTS,MCPD sharePoint 2010

    • Marked as answer by Patrick_Liang Sunday, December 1, 2013 2:51 PM
    Monday, November 18, 2013 8:21 PM

All replies

  • The easiest way to do this would be to use the built-in REST call to the Search service with a query that would filter to the sites and lists you need.  Take a look at the Content Search Web Part for perfecting the query.

    Paul Stork SharePoint Server MVP
    Principal Architect: Blue Chip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

    Friday, November 15, 2013 4:41 PM
  • That's fine but how to do the same in CAML query in client object model. The CAML query will be specified with URL and all the task lists in different  site collections with the access rights will be read.

    Regards,

    Chaitanya

    Monday, November 18, 2013 2:57 PM
  • You would have to translate it to a Keyword query to use search, but the parameters should be essentially the same.

    Paul Stork SharePoint Server MVP
    Principal Architect: Blue Chip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

    Monday, November 18, 2013 5:19 PM
  • Search is fine. Can u please guide me how to pass a server template value to a CAML query so that i can traverse all the site collections of it to extract information.

    Regards,

    Chaitanya

    Monday, November 18, 2013 5:21 PM
  • Sorry, but I'm not sure what your question is.  If you use Search as the basis for the query you won't use CAML.  Also, it will automatically traverse all site collections because search by default includes all the site collections.  If you want to search only specific site collections you can do that by limiting the search results based on URL Path.

    Paul Stork SharePoint Server MVP
    Principal Architect: Blue Chip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

    • Proposed as answer by Amr FouadMVP Monday, November 18, 2013 8:21 PM
    • Marked as answer by Patrick_Liang Sunday, December 1, 2013 2:51 PM
    Monday, November 18, 2013 6:14 PM
  • Like what Paul was referring to the easiest way to use Search API and you have two options 

    • Keyword Query

    for keyword query you can set SourceID(ResultType) , romlimit,Querytext

    in the querytext you can filter using the search manged property for example if you want to search by Content Type it will be like the following

     KeywordQuery Kq = new KeywordQuery(SPContext.Current.Site);
                //fileter content type
                Kq.QueryText += "ContentType:ArticlePage";
                 //you can pass the selected managed properties to be returned in the search result table by setting the selectproperties string array 
                //properties to select
                foreach (string prop in selectProperties)
                {
                    Kq.SelectProperties.Add(prop);
                }
                
                    Kq.SortList.Add("ManagedPropertyUsedToSort","descending");
                    
                
                
                Kq.RowLimit = itemLimit;
               Kq.TrimDuplicates = trimduplicates;
               ResultTableCollection results= new SearchExecutor().ExecuteQuery(Kq);
               return results.Filter("TableType", KnownTableTypes.RelevantResults).FirstOrDefault<ResultTable>();
            

    • RESTful API

    execute GET request using $ajax call (useful in JavaScript client side scenarios

    http://server:port/_api/search/query?querytext='ContentType:ArticlePage'&rowlimit=10&selectproperties='Author,Write'

    for full RESTful API guide see below 

    http://blogs.msdn.com/b/nadeemis/archive/2012/08/24/sharepoint-2013-search-rest-api.aspx

     


    Hope that helps|Amr Fouad|MCTS,MCPD sharePoint 2010

    • Marked as answer by Patrick_Liang Sunday, December 1, 2013 2:51 PM
    Monday, November 18, 2013 8:21 PM