Sharepoint 2010: Lookup columns in Data Views using SOAP & REST webservices

By peter.stilgoe









If you are using a webservice & a dataview to display list data across sites in Sharepoint 2010 you may come across this problem when displaying lookup columns.

A lookup field is stored in the format “ID;#Text”

When using a REST data connection the values returned for the lookup column is just the ID part of that item in the lookup list ie. “01″, I couldnt find a way how to return the text part of the lookup.

If you use a SOAP data connection it will retun the whole string ie, “01;#Blue”, so now we are getting the value but we dont want to display the the ID part or the ‘;#’ part. This is easily done changing the XSLT from

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

to

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

Now in your dataview instead of displaying “01;#Blue”, you will just be displaying the text value “Blue”.




Share

, , , , , , ,

About... peter.stilgoe

peter.stilgoeThis author published 497 posts in this site.
Sharepoint, InfoPath, K2, Nintex, Business Process Mapping, Business Intelligence, Automation, ECM, Document Management, Document Imaging, Internet Marketing & Online Business Consultant Email / MSN: pstilgoe@hotmail.com LinkedIn: Pete Stilgoe - Sharepoint Consultant









Share

FacebookTwitterEmailWindows LiveTechnoratiDeliciousDiggStumbleponMyspaceLikedin

2 Comments

  • At 2011.05.02 12:06, Bijay said:

    Hi thanks for sharing the information. I am also trying to explain the look up column here
    http://www.fewlines4biju.com/2011/05/look-up-column-in-sharepoint-2010.html

    Thanks
    Bijay

    [Reply]

    • At 2012.02.06 19:41, Scott said:

      I have connected my dataview to a querystring filter and want it to filter by one of my lookup columns. Unless I pass the exact ID, it won’t filter (I want to filter by the value name, in your example “Blue”; not “01:#Blue”). Do you know how to achieve this?

      [Reply]

      (Required)
      (Required, will not be published)