CQWP that lists all documents checked out to me

Hi everyone!

I thought I would show you how you could make the CQWP list all documents in your Site Collection that are checked out to me.

The thing is, if you set the CQWP to search the whole site collection or a site for that matter, and then choose “List Type” “Document Library” you will not be able to choose the filter “Checked Out To”.

So how should we do to then?

First of all if you navigate to “Site actions” and “Manage Content and Structure” and then choose “Content and Structure Reports” you will find the reports and the CAML that is used for them. What you should do is to copy the CAML query from the report “Checked Out To Me”.

<Where><Eq><FieldRef Name="CheckoutUser" LookupId="TRUE"/><Value Type="Integer"><UserID/></Value></Eq></Where>

Now, add a CQWP to your page and set it to search a site of your choice, set the “List Type” to “Document Library” and give it a name, chrome type and so on, but don’t set any filters.

Now export the CQWP and open it with Notepad.

Lookup the property “QueryOverride” and replace that row with this one:

<property name="QueryOverride" type="string"><![CDATA[<Where><Eq><FieldRef Name="CheckoutUser" LookupId="TRUE"/><Value Type="Integer"><UserID/></Value></Eq></Where>]]> </property>

As you can see I have already added the CAML from the report for you.

Now save this file somewhere and upload it to the web part gallery.

That’s it!

Now you have a web part you could add that will list all documents checked out to me.

CU!

/SPNiax


Get a link in a CQWP to edit an item

Hi everyone!

I hope this could be of some use for you 🙂

I want:

An audiense filtered list of links where by clicking the link, I should end up being able to edit the item, not open the page it points to. After I have finished editing I should return to the page with links targeted to me (or any other page for that matter).

Ok this is what we have:

A links list called OrgLinks where we have activated Audience targeting settings. This list also has a custom column called Box that is of the type Managed metadata which is connected to a Term store called Linkboxes.
So each item is tagged with which box it should belong to and which part of the organization that should see it.

I have a page that consists of a number of CQWP that is querying this links list. Audience targeting is activated on these web parts and they are filtered on the values of the Term store Linkboxes.

On the same page, I have added a couple of buttons (targeted to editors) to make it easier to create new items in this list and navigate to a page where you could edit items already created. This is actually the list that this blog is all about 🙂

The thing is that even if you enable Audience targeting for a list, you can’t OOTB filter a lists view on audiences.

This is where the template I came up with for ItemStyles.xsl comes in. It could be that I am crossing the brook for water in my template but it gives me the result I want 🙂

It was actually this template from Marc’s blog that got me in the right direction.

What it does is that it concatenate the link to the edit form of the item, the Item-ID and the URL to the page the user should go to after he or she is finished.

<xsl:template name="LinkListEdit" match="Row[@Style='LinkListEdit']" mode="itemstyle">
     <xsl:variable name="SafeLinkUrl">
         <xsl:call-template name="OuterTemplate.GetSafeLink">
             <xsl:with-param name="UrlColumnName" select="@URL"/>
         </xsl:call-template>
     </xsl:variable>
     <xsl:variable name="DisplayTitle">
         <xsl:call-template name="OuterTemplate.GetTitle">
             <xsl:with-param name="Title" select="@URL"/>
             <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
         </xsl:call-template>
     </xsl:variable>
     <xsl:variable name="TheList">
     <xsl:text disable-output-escaping="yes"> /alltomoss/_layouts/listform.aspx?PageType=6&amp;ListId={675357B2-D33C-4626-A61B-0FC978C0C09C}&amp;ID=</xsl:text>
     </xsl:variable>
     <xsl:variable name="Source">
     <xsl:text disable-output-escaping="yes">&amp;Source=/alltomoss/sidor/aoolankar.aspx</xsl:text>
     </xsl:variable>
          <xsl:variable name="TheLink">
          <xsl:value-of select="concat($TheList, @ID, $Source)" />
          </xsl:variable>
     <div id="linkitem">
         <xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
         <a href="{$TheLink}" title="Redigera länken">
         <xsl:value-of select="substring-after($DisplayTitle,',')"/>
         </a>
     </div>
 </xsl:template>

Before we actually could use this template and use it it in our CQWP we need to export the webpart and add a couple of things to it. Change CommonViewFields to look like this:

 <property name="CommonViewFields" type="string">URL,Text; </property> 

Then as “usual” import it again and add it to the page.

CU!

/Niax