0

I have two lists, let's say "Parent" and "Child". There is a lookup in "child" list that point to "parent".

In a custom view of Child list, I'd like to have the title of "Child" display, with a link to a custom page with the Parent ID in the url.

In the custom XSL of my child view, I have written :

<a href="{$ServerRelativeUrl}/Pages/myPage.aspx?MyID={substring-before(@Parent., string( ';'))}" title="Open parent">
    Open Parent
</a>

This is not working as expected, the myId argument is empty.

If I write instead :

<a href="{$ServerRelativeUrl}/Pages/myPage.aspx?MyID={@Parent.}" title="Open parent">
    Open Parent
</a>

MyID equals 1;#1, the value in SPFieldLookupValue form.

How can I properly extract the remote ID to build a link?

PS: I choose to use Xslt View webpart only for this purpose. If there is a better alternative solution do not hesitate to let me know.

1

I'd just break it down a bit and do the substring-before operation before using it to look at why your substring is going wrong.

<xsl:variable name="myId" select="substring-before(@Parent., ';')" />
Parent: <b><xsl:value-of select="@Parent."/></b><br />
myId: <b><xsl:value-of select="$myId"/></b><br />
<a href="{$ServerRelativeUrl}/Pages/myPage.aspx?MyID={$myId}" title="Open parent">
    Open Parent
</a>
  • Thanks, this help to see that there was an issue with my xsl. @Parent. was null, so I suppose I put my code in the wrong xsl template. To find the correct place, I use SPD, select CEll and start changing the content. This place was the correct place to put my customisation. – Steve B Jul 13 '12 at 8:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.