Cut off the xxx;# from a datasource field lookup in SharePoint

If you work with SharePoint and SharePoint Designer to create your own pages to show fields, you probably want to do the same with lookup fields. But if you add a lookup field, you get a nasty code referencing to the item number included in the field. Luckily, in SharePoint Designer you have access to the code of the field:

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

Just change that line to the following :

<xsl:value-of select="substring-after(@Fieldname, ';#')" />

What this code does is take a part of the text that is displayed there: It only takes the part after the ;# .

About: Marijn

Marijn Somers (MVP) has over 14 years experience in the SharePoint world, starting out with SP2007. Over the years the focus has grown to Office 365, with a focus on collaboration and document management. He is a business consultant at Balestra and Principal Content Provider for "Mijn 365 Coach" that offers dutch employee video training. His main work tracks are around user adoption, training and coaching and governance. He is also not afraid to dig deeper in the technicalities with PowerShell, adaptive cards or custom formatting in lists and libraries. You can listen to him on the biweekly "Office 365 Distilled" podcast.