Lookup column in library

Copper Contributor

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 a lookup column to this new content type itself.

It works but when i choose which data to show in the list of choices for the user to set the link, i see some columns but not the "name" column, inherited from the document content type. For the user, to select an id or else is not significant.

My question is : why i can't choose the name column ? And how tu fix this ?

Thank you !

1 Reply

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