SharePoint having an option to get a reference from another list using Lookup column. We can also able to pull some additional column values from the list. We can do this manually while editing the lookup column.
Here, I am going to give a powershell script to enable this
$web = Read-Host "Enter site URL : "
$spweb= Get-SPWeb $web
$listParent = $spweb.Lists["Parent List Name"]
$listChild = $spweb.Lists["Child List Name"]
Write-Host "Applying AddDependentLookup" -ForegroundColor Magenta
#Getting lookup column from child list
$lookupField = $listChild.Fields["LookupField"]
$newField= $listChild.Fields.AddDependentLookup("New Column Name",$lookupField .Id)
$secondary = $listChild.Fields.GetFieldByInternalName($newField)
$secondary.LookupField = $listParent.Fields["New Column Name"].InternalName
$secondary.update()
Write-Host "Applied AddDependentLookup" -ForegroundColor Green
Can you tell me what "$riskIDField.Id" is?
ReplyDeleteHello, I could not understand this script. And this get-spweb is not working. When I tried to load the module using 'Add-PSSnapin Microsoft.Sharepoint.Powershell' it throws an error 'No snap-ins have been registered for Windows PowerShell version'
ReplyDelete