Sharepoint Designer: Fetching ID of Lookup Field from Label

In sharepoint , on display pages of any list, all the fields are rendered as Label, This creates problem when customization is required having some link of lookup field( rendered as label) from that page.

Since it is label @lookupfieldname returns the value(in text format) of that field not ID for that field value.

For this there is inbuilt function called ddwrt:URLLookup with arguments in following order:

  • GUID of List from which that lookup field belongs
  • Display name of lookup field for current list
  • string(@ID) is to bind value with currrent id of item displayed from current list

so in sample case function for that lookupfield will look like

ddwrt:URLLookup(‘{218F74EE-A2C0-4D22-B8E1-BD91B2F36437}’,’MyContact’, string(@ID)))

where

  • The GUID is the ListId of the Contacts List (change accordingly !)
  • ‘MyContact’ is the internal field name of the lookup field created in the custom list (change accordingly !)
  • @ID passes the reference to the current item for which you want to get the lookup item url