Press ESC to close

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

Jasper Oosterveld

My name is Jasper Oosterveld. I am a Microsoft MVP, Data Security & Microsoft 365 Consultant based in the Netherlands. I’ve spent the last decade helping organizations tackle complex challenges around Governance, Adoption and Data Security with Microsoft Purview. My mission? To empower companies to protect their data and streamline collaboration in Microsoft 365, all while keeping governance and adoption at the forefront.

Comments (1)

Leave a Reply

Your email address will not be published. Required fields are marked *

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