How to Aggregate List Items Across Sites with Url?

Below is my sample script to pull all blog posts on the site collection.

I  am having trouble providing the url of each item when using the CreateSPSiteDataQuery


## Setup site data query inputs
#set( $viewFieldsXml = "<FieldRef Name='FileRef' /><FieldRef Name='EncodedAbsUrl' /><FieldRef Name='FileDirRef' /><FieldRef Name='Title'/><FieldRef Name='Created' /><FieldRef Name='Author' /><FieldRef Name='Modified' /><FieldRef Name='Editor' /><FieldRef Name='PostCategory' />" )
#set( $listsXml = "<Lists ServerTemplate='301' />" )
#set( $websXml = "<Webs Scope='SiteCollection'/>" )
##set( $queryCaml = "<Where><IsNotNull><FieldRef Name='PostCategory' /></IsNotNull></Where><OrderBy><FieldRef Name='Modified' Ascending='False' /></OrderBy>" )
#set( $queryCaml = "<Where><Gt><FieldRef Name='Modified' Type='DateTime' /><Value Type='DateTime'><Today OffsetDays='-30' /></Value></Gt></Where><OrderBy><FieldRef Name='Modified' Ascending='False' /></OrderBy>")
## Create the site data query   
#set( $siteDataQuery = $SPUtility.CreateSPSiteDataQuery($viewFieldsXml, $listsXml, $websXml, $queryCaml, 10) )
## Execute the site data query
#set( $dataTable = $web.GetSiteData($siteDataQuery) )

#foreach($dataRow in $dataTable.Rows)
    <table class="ms-listviewtable" cellpadding="3" cellspacing="0" border="0" width="100%">
      <tr class="ms-viewheadertr">
 <th class="ms-vh2-nofilter"></th>
        <th class="ms-vh2-nofilter">Categories</th>

        <th class="ms-vh2-nofilter">Title</th>
        <th class="ms-vh2-nofilter">Created</th>
        <th class="ms-vh2-nofilter">Author</th>
        <th class="ms-vh2-nofilter">Modified</th>
        <th class="ms-vh2-nofilter">Editor</th>
      <tr class="">
      <tr class="ms-alternating">
 <td class="ms-vb2"><img src="/_layouts/images/STS_ListItem16.gif" /></td>
        <td class="ms-vb2">
  #set ( $Category = $Expressions.Split($dataRow.get_item("PostCategory"), "#") )
        <td class="ms-vb2">
  #set ( $FileRef = $Expressions.Split($dataRow.get_item("FileRef"), "#") )

        <td class="ms-vb2">$dataRow.get_item("Created")</td>
        <td class="ms-vb2">
  #set ( $Author= $Expressions.Split($dataRow.get_item("Author"), "#") )
        <td class="ms-vb2">$dataRow.get_item("Modified")</td>
        <td class="ms-vb2">
  #set ( $Editor= $Expressions.Split($dataRow.get_item("Editor"), "#") )
    No KB Found



Have more questions? Submit a request


  • 0
    Permanently deleted user


    I'm not sure I fully understand your issue. It sounds like you are not able to pull the URL from the DataTable returned from the GetSiteData query. Is this correct?



  • 0
    Fernandes, Denzil

    Correct.... here is what I am temporarily doing to create the URL to the Blog Post...



    Can't see how in the aggreate query to specify the displayform url

  • 0
    Fernandes, Denzil

    Here is how you do it....

    ## Get display url information
    #set( $sourceUrlEncoded = $HttpUtility.UrlEncode($request.RawUrl) )
    #set( $displayForm = $list.Forms.get_item($PAGETYPE_PAGE_DISPLAYFORM) )


    I get i need my display form to bind the list , but i couldnt find any samples where u have dont something like this on the help pages for datazoom

  • 0
    Permanently deleted user


    We have similar code on our Get List Items by CAML sample....

    (Get List Items By CAML)

    You can also find more complex examples on our script libary...

    (Data Zoom Script Library)

Please sign in to leave a comment.