0

I want to create lookup column with multi select option using PNP PowerShell in SPO.

I am able to create lookup field below script. But i dont know what is the property to be added to make it multi select field. Also, I need to select 2 more columns as additional fields. How to include it.

$SiteURL = "****"
$ListName= "Projects"
$DisplayName = "Parent Project"
$InternalName = "ParentProject"
 
$ParentListName="Parent Projects"
$LookupField = "Title" #Internal Name
 
#Connect to the site
Connect-PnPOnline -Url $SiteURL -Interactive       
 
#Add Lookup Field to the List    
Add-PnPField -List $ListName -Type Lookup -DisplayName $DisplayName -InternalName $InternalName -AddToDefaultView
 
#Set Field Properties
Set-PnPField -List $ListName -Identity $InternalName -Values @{LookupList=(Get-PnPList $ParentListName).Id.ToString(); LookupField=$LookupField}
0

1 Answer 1

2

You are looking for the field property AllowMultipleValues which you want to set to $true.

Set-PnPField -List $list -Identity $InternalName -Values @{LookupList=(Get-PnPList $ParentListName).Id.ToString(); LookupField=$LookupField; AllowMultipleValues=$true}

FieldLookup.AllowMultipleValues property

If you want to add additional columns related to the lookup-column, I think the only way is to do it using Add-PnPFieldFromXml.

Create lookup field with additional columns

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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