Question

When we create lookup column OOTB, there is option "Add a column to show each of this additional fields", so that we can have more than one show fields in list for that lookup.

But how to do same thing if we are creating List by visual studio?

Please have a look at following screenshot for more ref. enter image description here

Was it helpful?

Solution

To setup the additional field from the lookup, you need to add a second lookup field pointing at the same list, but include the FieldRef attribute on the second lookup field. The value of this attribute should be the same as the ID attribute of the first lookup field.

<Field ID="{5D184D01-082C-4831-8757-CA2C98F05221}" Name="Title" DisplayName="Title" Type="Lookup" Required="FALSE" Group="<GROUP>" ShowField="Title" List="Lists/EmpConfiguration"></Field>

Additional field can be added as follows:

<Field ID="{393F697A-7F99-488E-B67F-41DFD6D41857}" FieldRef="{5D184D01-082C-4831-8757-CA2C98F05221}" Name="EL" DisplayName="EL" Type="Lookup" Required="FALSE" ShowField="ID" List="Lists/EmpConfiguration"></Field>

Notice the ID of first field and FieldRef id of second field is same.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top