Microsoft 365 SharePoint

Content Query Web Part open item in edit view

I like the CQWP and how you can load items from other locations. The default action behind an item that is shown by the CWQP is loading the display view. I really wanted to open the edit mode. Thanks to the Internet and my colleague Marnix I figured it out! You have to follow these instructions:

  • Open SharePoint Designer
  • Click at All Files
  • Click at Style Library
  • Click at XSL Style Sheets
  • Make a back-up of ContentQueryMain and ItemStyle
  • Check out ContentQueryMain and add the following code:

<xsl:template name=”OuterTemplate.GetEditLink”>
<xsl:param name=”UrlColumnName”/>
<xsl:if test=”$UseCopyUtil = ‘True'”>
<xsl:value-of select=”concat($RootSiteRef,’/_layouts/CopyUtil.aspx?Use=id&amp;Action=editform&amp;ItemId=’,@ID,’&amp;ListId=’,@ListId,’&amp;WebId=’,@WebId,’&amp;SiteId=’,$SiteId,’&amp;Source=’,$Source)”/>
</xsl:if>
<xsl:if test=”$UseCopyUtil != ‘True'”>
<xsl:call-template name=”OuterTemplate.GetSafeStaticUrl”>
<xsl:with-param name=”UrlColumnName” select=”$UrlColumnName”/>
</xsl:call-template>
</xsl:if>
</xsl:template>

  • Save and check in and publish
  • Check out ItemStyle and add the following code:

<xsl:template name=”NameOfTheTemplate” match=”Row[@Style=’ NameOfTheTemplate’]” mode=”itemstyle”>
<xsl:variable name=”SafeLinkUrl”>
<xsl:call-template name=”OuterTemplate.GetEditLink”>
<xsl:with-param name=”UrlColumnName” select=”‘LinkUrl'”/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name=”DisplayTitle”>
<xsl:call-template name=”OuterTemplate.GetTitle”>
<xsl:with-param name=”Title” select=”@Title”/>
<xsl:with-param name=”UrlColumnName” select=”‘LinkUrl'”/>
</xsl:call-template>
</xsl:variable>
<div>
<xsl:call-template name=”OuterTemplate.CallPresenceStatusIconTemplate”/>
<a onclick=”javascript:SP.UI.ModalDialog.ShowPopupDialog(‘{$SafeLinkUrl}’); return false;” onmouseover=”javascript:this.style.cursor=’hand’;” title=”{@LinkToolTip}”>
<xsl:value-of select=”$DisplayTitle”/>
</a>
</div>
</xsl:template>

  • Save, Check in and Publish.

The last thing you have to do is edit the CQWP and use the itemstyle. That should do the trick!

I want to thank the author of this article:
http://www.aaune.org/wiki/index.php?title=CQWP_Direct_link_to_Editform

You Might Also Like

1 Comment

  • Reply
    Microsoft…what else? – SharePoint – Content Query Web Part open item in detail view
    February 26, 2014 at 8:13 am

    […] wrote an article about opening an item with the CQWP in the edit form. I also found out how to open an item with […]

  • Leave a Reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.