0

I'm using this xml in order to declare a lookup column :

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">  
 <Field
   ID="{2360b46a-f4b9-4cd5-b8a3-98eca46b0067}"
   Name="FromDuration"
   DisplayName="From Duration"
   Type="Lookup"
   ShowField="Title"
   List="Lists/DurationSettings"
   Overwrite="TRUE"
   Required="TRUE"
   Group="Leave Request App Group">
   </Field>
  </Elements>

Even though it is declared ok , i don't get any values in the lookup field.

Any ideas what i'm doing wrong?

  • Is your DurationSettings List contains list items ? – Youssef Moumen El idrissi Sep 14 '17 at 9:36
  • Yes it does . I have list items with Fields : Title (the default one) and Hours . So it has two fields. The list items are added through the SharePoint add-in hardcoded but i also tried to add some manually . The lookup fields won't read them. I think something is wrong with the mapping of the lookup field and the title field – shak Sep 14 '17 at 11:54
1
<Field ID="{8b26ec41-b6c3-4327-0066-0c18c0768626}" Name="InternalName" StaticName="InternalName" DisplayName="Display Name" Type="Lookup" ShowField="Title" Mult="TRUE" List="Lists/LookupList" Overwrite="TRUE" />

Useful links Check this once.

Link 1

Link 2

  • May b this link will useful to create lookup column in SharePoint Apps using XML. – san Sep 14 '17 at 9:05
  • Thanks for the help but i still don't understand. I create Site Columns , i add them to the Site Content Types and then add the Content Type to the list. I added the column "From Duration" into the Contenty Type and then into the list. Do i need to write code to add this field? For standard fields all i do is create them and add them to Site Content type. Now i need to add the lookup field programmatically by using clientContext? – shak Sep 14 '17 at 11:52
  • No need to write code. You just open default.xml file and add the lookup field. Note the lookup to the list which is accomplished purely with declarative XML courtesy of the “List="Lists/DurationSettings" Check this link – san Sep 15 '17 at 2:38
  • Still doesn't work. Are you sure this works? Have you tested it ? Don't know why it doesn't work. Its a simple lookup field – shak Sep 18 '17 at 10:05
0

The solution is to give priority to the feature which deploys the list that you want to lookup for (the source list). You can do that by changing the feature activation order in the Package manifest.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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