1

I switched from InfoPath to the Designer forms. In the list I have a Lookupfield that Points to another list. In the Control modes Edit and New the select boxes are created automatically using the usual elements

<SharePoint:FormField runat="server" id="ff6{$Pos}" ControlMode="Edit" FieldName="Betrieb" __designer:bind="{ddwrt:DataBind('i',concat('ff6',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Betrieb')}"/>
<SharePoint:FieldDescription runat="server" id="ff6description{$Pos}" FieldName="Betrieb" ControlMode="Edit"/>

The Problem arises in the ViewForm, where I usually use the following:

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

But since Betrieb is a Lookup field, it creates an a element and in the form i see:

<a href="http://portal/projects/buchungsportal/_layouts/15/listform.aspx?PageType=4&ListId={f1b5206b-3d88-4ea3-8aba-6c26b9dd07f8}&ID=1146&RootFolder=*">THE VALUE I WANT TO DIAPLAY</a>

How do I extract only THE VALUE I WANT TO DISPLAY?

2 Answers 2

3

You need to use the substring options available in XSLT to get what you want substring-before and substring-after. Like this:

<xsl:value-of select="substring-before("&le;/a&gt;", substring-after("*&quot;&gt;", @Betrieb))"/>

Not fully tested, the encodings might be off for the greater than, less than, and double quote characters.

Edit: This also works, it will render a hyperlink though, not the value.

4
  • Well, ist a Little bit dirty... i thought there would be a SharePoint Feature or something else.
    – Emaborsa
    Commented Jan 7, 2015 at 14:15
  • That's just the way Lookup columns work in Sharepoint and DVWPs/XSLT, they are stored as an ID value pair. You could try the <xsl:value-of select="@Betrieb" disable-output-escaping="yes"/> but I don't think that is going to give the right result. Commented Jan 7, 2015 at 14:35
  • <xsl:value-of select="@Betrieb" disable-output-escaping="yes"/> Works, it puts the a tag as HTML instead of a simply text node. Thanks Man!
    – Emaborsa
    Commented Jan 7, 2015 at 14:47
  • Ok, when you said the value, I thought you wanted just the display name of the Lookup field which is why I went the substring route. Using the disable-output-escaping will render as a hyperlink. Commented Jan 7, 2015 at 15:10
2

select above should be:

    substring-before(substring-after(@Lookup, '&gt;'), '&lt;/a&gt;')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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