6

I'm trying to use the Visual Studio 2012 SharePoint 2013 List designer to create a lookup field but it is not working

Using the designer I created a simple list (Ad Agencies) with a column (Agency Name) that I want to appear as a lookup column in a second list.

Again, using the designer I created another list and add a Lookup column. Then using the property pane I set the following Properties for the Lookup column under "Type".

List: Ad Agencies
ShowField: Agency Name

I deploy the solution and add an item to the Ad Agencies list. I then add an item to the other list but the lookup Ad Agency column contains nothing.

I am hoping someone can spot what I may be doing wrong sinse this seems so straight forward.

Thanks for reading

Purnil Soni
  • 831
  • 4
  • 18
ChiliYago
  • 11,341
  • 23
  • 79
  • 126

2 Answers2

5

Solution

In your lookup column properties (i.e. using Property Pane), use below values:
List: Lists/Ad Agencies (Note: we are using "Lists/" before the list name)
ShowField: AgencyName (Note: there is no space between Agency and Name)

More Info

List:

This is "List URL (site-relative URL)" value of your parent list; found under "List" tab in visual studio 2012's list designer
enter image description here

ShowField:

This is name property value of your field in parent list that is to be used as ShowField (as shown in property pane) (note: this is not "display name" property value)

enter image description here

Please refer the below blog post for more

http://jsuhail.blogspot.com/2014/08/add-lookup-column-through-visual-studio.html

Community
  • 1
  • 1
Purnil Soni
  • 831
  • 4
  • 18
  • Does not work. My opinion says the designer does not work. Instead I am attempting to adding the lookup field in the onactivated event. – ChiliYago Aug 18 '13 at 02:19
  • @ChiliYago It does work. I tried your situation with above values and found them to work fine. Have added more info to the answer. Let me know if you are making any other customization to your lists. – Purnil Soni Aug 18 '13 at 06:18
  • i have not been able to make this work. That is exactly what I have done but no matter what I do the lookup list remains empty. It may be perhaps something related to this http://derekgusoff.wordpress.com/2013/04/26/declaratively-provisioning-a-lookup-column/ – ChiliYago Aug 18 '13 at 13:25
  • One more thing to check is that in the feature file, you must have parent list being deployed before the child list – Purnil Soni Aug 18 '13 at 16:58
  • Also can you let us know the values of 'list' and 'showfield' properties you are using, as the one mentioned in question are wrong and won't work – Purnil Soni Aug 18 '13 at 17:01
  • This worked perfect for me. I did note that if your column is named somethign that might be a reserved name (Name, Type, Title, etc) it might have changed the name of the column in the background (Name1, Type1, Title1, etc). – xdumaine Sep 16 '13 at 18:40
0

Ok I found the issue I was having. I was renaming the title Column. Do not do this. It causes all kinds of problems when trying to add list items using the list view as well.

If you rename the initial title field you have to reference it as

List: Lists/"Your List URL"
ShowField:Title"

no matter what you change the title name too. Oh don't get any ideas about changing the static name in the schema either. This does nothing but confuses SharePoint. Oh you can change the view to display your renamed title field but when editing it using the list edit view. SharePoint get confused.

It is best to delete the initial column and create a new one. Then you wont have any issues at all.

I repeat DELETE the initial column named Title. Then create your own if you do not wish to use the title field.

McFrank
  • 331
  • 3
  • 11