none
Custom List Form for Display with Multi-value Lookup

    Question

  • I have created a Custom List Form for displaying items in a List (A). One of the fields is a lookup of another List (B) for which there can be multiple values.

     

    In the standard SharePoint DispForm.apsx, the value of the lookup field is displayed as links to the display view of each List B item on a new line like so:

    Item 1

    Item 2

     

    When you create a Custom List Form, this instead produces a string of the text values from List B like so:

    Item 1;Item 2

     

    I have seen two solutions to getting the Custom List Form to display like the default DispForm.aspx but both have isses:

    1. Set the 'Item 1;Item 2' to display as List Form Field and can the view from 'Edit' to 'Display' (as provided by Quincy in this post: http://social.msdn.microsoft.com/Forums/en-US/sharepointcustomization/thread/f5ca14c2-925b-4f8d-b306-f7c3d1696be3/). This works perfectly with the items linked to the correct items in List B. However, it shows the value from the first row of List A for every row instead of the value for the corresponding row.

    2. Use XSL to call a procedure which looks for ';' and splits the string into new lines. Then add a link around this. This works and shows the correct values for each list item we view. However, the link cannot be 'DispForm.aspx?ID=x' as the lookup doesn't store the ID. We can use 'DispForm.aspx?Title=x' but this just opens an blank version of the DispForm.aspx!

     

    There are a few posts on here asking the same thing and these solutions are from those topics. There appears to be no answer though. Has anyone found a way of doing it?

    Tuesday, August 23, 2011 4:47 PM

Answers

  • Hi ajr87,

     

    I have a test in my local server, format the lookup field with List Form Field, it works well for every item in list B.

     

    Here are my steps:

    1.       Create two lists, listA, listB, listA has a lookup field(allow multi values) from listB.

    2.       In SharePoint Designer, open DispForm.aspx of listA, hide the default form, create a Custom List Form for listA.

    3.       Click the lookup field, right click the arrow->Format Item as->List Form Field.

    4.       In code view, find SharePoint FormField tag, replace the controlmode="Edit" to controlmode="Display"

    5.       Check in UI, the lookup field in each item shows correct and the items in lookup field can link to the corresponding item in listB.

    Please check the Custom List Form, whether there are additional steps in it, if convenient, you may try creating a new one to test.

     

    If the issue persists, would you please provide more information about your operation steps?

     

    Thanks,
    Qiao Wei

    Thursday, August 25, 2011 10:29 AM
    Moderator

All replies

  • Hi ajr87,

     

    I have a test in my local server, format the lookup field with List Form Field, it works well for every item in list B.

     

    Here are my steps:

    1.       Create two lists, listA, listB, listA has a lookup field(allow multi values) from listB.

    2.       In SharePoint Designer, open DispForm.aspx of listA, hide the default form, create a Custom List Form for listA.

    3.       Click the lookup field, right click the arrow->Format Item as->List Form Field.

    4.       In code view, find SharePoint FormField tag, replace the controlmode="Edit" to controlmode="Display"

    5.       Check in UI, the lookup field in each item shows correct and the items in lookup field can link to the corresponding item in listB.

    Please check the Custom List Form, whether there are additional steps in it, if convenient, you may try creating a new one to test.

     

    If the issue persists, would you please provide more information about your operation steps?

     

    Thanks,
    Qiao Wei

    Thursday, August 25, 2011 10:29 AM
    Moderator
  • Thanks Qiao,

    This is exactly what I needed. I've been searching for a solution like this for about a month. Thanks!

    Mike


    Michael L. Williams

    Wednesday, August 08, 2012 5:22 PM
  • Hello Qiao,

    My List Form field still list them on the same line.

    Test1; Test2; Test 3

    Mikw


    Michael L. Williams

    Monday, August 20, 2012 6:55 PM