SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two lists: Projects and Tasks

In the Tasks list, I have created a lookup field titled ProjectID which targets ID filed from the Projects list. Also, I have set for this field to display an additional field ProjectID: Title. So, when I view the tasks I see the values for the particular project ID and Title.

However, on the display form for the Tasks I can only see the ProjectID field. I've modified the display form to hide the default display web part and created a custom one in order to be able to customize the fields presentation. Now I have two problems:

  1. ProjectID field is displaying the whole <a... /> tag instead of just the value for the ID (which should act as a link to the related project item)
  2. I can't find a way to display the ProjectID:Title field at all. I tried:
    <td width="400px" valign="top" class="ms-formbody">
        <xsl:value-of select="@ProjectID_x003a_Title" />
    </td>
    but the field is just blank.

Is there a way to be able to show lookup additional field in the display form?
Thanks.

share|improve this question
    
Is there a solution to that question after more than a year now? I need this, too. Look here: http://sharepoint.stackexchange.com/questions/74523/sp2010-how-to-display-a-loo‌​kup-column-in-a-aspx-displayform – KarstenK Aug 7 '13 at 12:59

[There was a not useful answer]

UPDATE: OK, I understand the problem now. In my case the field is present in the section (I've removed other fields for simplicity):

<DataFields>@MultiLookupTest_x003a_TestField,MultiLookupTest:TestField;</DataFields>

And then you can render it just in the same manner as others but you need to use a part of identifier:

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

Unfortunately you'll get your projected value in the same form of tag. But here there's an advice:

I found another solution by selecting the cell and clicking "format as label".

Maybe it hepls you.

share|improve this answer
    
By default it works fine, but if you want to customize it then the problems appear. Open the DispForm.aspx in SharePoint Designer. Next, hide the default display web part. Next, go to Insert > SharePoint > Custom List Form and choose the same list and item display form type. The lookup field will get screwed up as described in the question and the lookup additional field will be missing and so on. – Boris Feb 28 '12 at 12:03

You could use the 2010FilteredLookup addon from Codeplex. It is free and it allows you to have a lookupfield that is cross-site and returns multiple columns. You can even filter by list view or caml query.

But it will display more than one column - both the ID and Title and whatever you like as different columns in your list.

share|improve this answer

As for rendering field without escaping you should use following attribute:

<xsl:value-of disable-output-escaping="yes" select="@MultiLookupTest_x003a_TestField"/>

From MSDN:

disable-output-escaping

Default is "no". If the value is "yes", a text node generated by instantiating the element will be output without any escaping.

Consider disable-output-escaping="yes" an advanced feature, to be used only when the potential dangers are understood.

share|improve this answer

For parts 1 and 2 of your question: Not sure if this helps (I'm on SharePoint Online [2013]), but try using the SharePoint:CreatedModifiedInfo tag as suggested here to show properly hyperlinked version rather than all of the HTML tags. It worked for a custom field I did, though I had to remove an extra line of code from the original answer to avoid a duplicate. Here's what your code might look like:

<tr>
    <td valign="top" class="ms-formlabel">
        <nobr>Project Title</nobr>
    </td>
    <td valign="top" class="ms-formbody">
        <SharePoint:CreatedModifiedInfo ControlMode="Display" runat="server">
            <CustomTemplate>
                <SharePoint:FormField FieldName="ProjectID:Title" runat="server" ControlMode="Display" DisableInputFieldLabel="true" />
            </CustomTemplate>
        </SharePoint:CreatedModifiedInfo>
    </td>
</tr>

As a general other solution: If you don't need to display the ID at all anywhere and just want to show the title, how about trying to change the display through the column itself? If you go to the column in List Settings from the list's webpage, you can choose to display the title while still looking up through the ID by changing the only dropdown on the page to Project Title or whatever the field's name is (I left the ID field checked in the additional column list). When you go back to look at the field in a dropdown from another form like the new or edit forms, you will see the titles of the projects rather than the ID numbers.

share|improve this answer

You can set "readonly" property of your additional field to FALSE (by code or sharepoint manager, for example). Then this field will be presented in display form.

share|improve this answer
    
Do you mean to do that in the source list or somewhere in the list doing the lookup? And do you mean Sharepoint Designer when you say "sharepoint manager"? – bgmCoder Aug 3 '13 at 15:23

Your Answer

 
discard

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

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