Forum Discussion
ogoret
Jan 07, 2023Copper Contributor
Lookup column in library
Hi, I have created a content type, which inherit from "document". So it has a column "name" inherited. I would like to add a column to link elements between them. So i add in my new content type...
SvenSieverding
Jan 09, 2023Bronze Contributor
HI ogoret
You can set it using PNP Powershell.
$ListName="Documents"
$LookupFieldName="RelatedDocument"
# Add the field to the list
Add-PnPField -List $ListName -Type Lookup -DisplayName $LookupFieldName -InternalName $LookupFieldName -AddToDefaultView
# Set the lookup list for the field and set the lookup field to "FileLeafRef"
Set-PnPField -List $ListName -Identity $LookupFieldName -Values @{LookupList=(Get-PnPList $ListName).Id.ToString(); LookupField="FileLeafRef"}
The "name" field you need to reference is internally called "FileLeafRef".
It is a special field, perhaps that is why you can't select it using the UI.
Best Regards,
Sven