6
votes

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

2

2 Answers

5
votes

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

0
votes

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.