Hi @SR VSP ,
Long time no see, how are you?
Please run the below PnP PowerShell script as an admin. It's worth noting, don't create more than 12 Lookup columns(fields) in the same list.
#Config Variables
$SiteURL = "https://domain.sharepoint.com/sites/sitename"
$ListName= "ListNameA"
$ParentListName="ListNameB"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)
#Get the ID of the Parent List
$LookupListID = (Get-PnPList -Identity $ParentListName).ID
#Define XML Schema for Text Field
$ProjectCodeFieldXML= "<Field Type='Text' Name='ProjectCode' ID='$([GUID]::NewGuid())' DisplayName='Project Code' Required ='FALSE' EnforceUniqueValues = 'TRUE' Indexed='TRUE'></Field>"
#Define XML Schema for Multiline Text Field
$ProjectDescriptionFieldXML= "<Field Type='Note' Name='ProjectDescription' ID='$([GUID]::NewGuid())' DisplayName='Project Description' Required ='FALSE' RichText='TRUE' RichTextMode='FullHtml' ></Field>"
#Define XML Schema for Choice Field
$PriorityFieldXML= "<Field Type='Choice' Name='Priority' ID='$([GUID]::NewGuid())' DisplayName='Priority'>
<CHOICES>
<CHOICE>(1) High</CHOICE>
<CHOICE>(2) Normal</CHOICE>
<CHOICE>(3) Low</CHOICE>
</CHOICES>
<Default>(2) Normal</Default>
</Field>"
#Define XML Schema for Lookup Field
$ParentProjectFieldXML= "<Field Type='Lookup' Name='ParentProject' ID='$([GUID]::NewGuid())' DisplayName='Parent Project' List='$LookupListID' ShowField='Title'></Field>"
#Add Text Field to list from XML
Add-PnPFieldFromXml -FieldXml $ProjectCodeFieldXML -List $ListName
#Add Multiline Text Field to list from XML
Add-PnPFieldFromXml -FieldXml $ProjectDescriptionFieldXML -List $ListName
#Add Choice Field to list from XML
Add-PnPFieldFromXml -FieldXml $PriorityFieldXML -List $ListName
#Add Lookup Field to list
Add-PnPFieldFromXml -FieldXml $ParentProjectFieldXML -List $ListName
Here is my test:
Thanks,
Echo Du
======================================
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.