I am using SharePoint Framework to provision list and libraries according to the below article:
I was able to deploy lists and libraries using above approach. How do I add lookup field using SharePoint Framework please?
I am using SharePoint Framework to provision list and libraries according to the below article:
I was able to deploy lists and libraries using above approach. How do I add lookup field using SharePoint Framework please?
you can add the following xml code in elements.xml file in sharepoint/assets folder and replace the properties accordingly
<Field
ID="{6C798145-A205-4FC4-8175-837B0F7744CC}"
Type="Lookup"
DisplayName="Colors"
Required="false"
List="F7CD8F64-A506-4FB5-8A63-B9268CD7D1E4"
ShowField="Color"
UnlimitedLengthInDocumentLibrary="TRUE"
Group="Test"
StaticName="Colors"
Name="Colors"
Version="1" />
If list to lookup is created in the same feature as the Field then:
Type="Lookup"
List="Lists/My List"
https://docs.microsoft.com/en-us/sharepoint/dev/schema/field-element-field
List Optional Text. Used to identify the list that is the target of a lookup field (Type="Lookup"). If the target list already exists, the value of the List attribute should be the string representation of the GUID (including braces) that identifies the target list. If the target is the same list as the one that the field belongs to, you can specify "Self". If the target list does not yet exist, the value of the List attribute can be a web-relative URL such as "Lists/My List" but only if the target list is created in the same feature as the one that creates the lookup field. In this case, the value of the List attribute on the Field element must be identical to the value of the Url attribute on the ListInstance element that creates the target list.