Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a Data View Part pulling from a list that has a lookup column to another list (title linked by ID)

And somewhere in the XSLT, it reads

<xsl:value-of select="@ColumnX"/>

Now since ColumnX is a reference to another list, how do I go about obtaining the ID rather than the text? Is there a ddwrt trick out there?

Note If you were to run the same CAML used by the Data View Web Part, you will notice that the ID of the referenced column is part of the result. E.g.

ows_ColumnX
12;#Bill Peet
13;#Erdman

ps: It seems and I could be wrong that the DVWP removes the IDs so things like substring-before(string, string) won't work.

share|improve this question
    
Have you checked to ensure that the value of @ColumnX includes the ID if you just output the variable raw. Obviously your not going to be able to peform substring operations is the original string doesn't have the ID. Im not talking about executing the same CAML query externally as you did, I mean output the value of @ColumnX and see what is contained within. –  Charles Lee Mar 31 '10 at 21:01
    
@Charles Lee, @ColumnX is one of those (title linked by ID) columns so it does contain the ID. –  Anonymous Apr 1 '10 at 13:54
    
has anyone found a solution to this? –  user4490 Aug 19 '11 at 14:49

3 Answers 3

The ID won't be there. You'll need to look up the value in the source list to get at the ID:

<xsl:variable name="LookupID" select="/dsQueryResponse/List2/Rows/Row[@Title = current()/@ColumnX]"/>
share|improve this answer
    
I'll try this approach in the XSLT, but based on what I've experienced, it seems DWVP extacts the IDs from "linked" columns.. we'll see. –  Anonymous Apr 1 '10 at 14:02
    
Without seeing your full setup, it's hard to say. Yes, the IDs are often stored so that you can access them. –  Marc D Anderson Apr 2 '10 at 13:50

try the xslt function substring-before()

share|improve this answer
    
<xsl:value-of select="substring-before(@ColumnX, ';')"/> returns empty. –  Anonymous Mar 31 '10 at 20:25
    
try replacing @ColumnX with the hardcoded "12;#Bill Peet" string and see if this returns the ID. Maybe @ColumnX does not contain what you think it should contain. Can you post the full xlst? –  Jaap Vossers Apr 1 '10 at 8:48
    
Thanks Jaap, but that won't work. @ColumnX must be there to obtain the real value rather than a hard coded value. –  Anonymous Apr 1 '10 at 13:41
    
I understand, but if you hardcode the value just to test, then you can tell if the problem lies with the value of @ColumnX or the result of the function. –  Jaap Vossers Apr 1 '10 at 20:20
    
It's without a doubt that the ddwrt function substring-before will do its job, but that's not the problem.. –  Anonymous Apr 2 '10 at 15:24

You're looking for the ID in the lookup list that relates to the textual value that is actually stored in the child list?

share|improve this answer
    
It's a column referencing to another list (Linked to item) so the ID is part of the result set when using CAML. The Data View Web Part or more specifically the XSLT should allow me to pull this value, how? –  Anonymous Mar 31 '10 at 14:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.