Skip to content

Instantly share code, notes, and snippets.

@emiliano-poggi
Last active May 9, 2016 11:20
Show Gist options
  • Save emiliano-poggi/3616e307e89eb2eb7a1a6aa028198ad5 to your computer and use it in GitHub Desktop.
Save emiliano-poggi/3616e307e89eb2eb7a1a6aa028198ad5 to your computer and use it in GitHub Desktop.
Fix SharePoint 2013 Field Link missing from List Content Type, Lookup Field, Additional Fields

Fix SharePoint 2013 Field Link missing from List Content Type, Lookup Field, Additional Fields

You have a List Content Type with a Lookup Field for which you cannot set additional lookup fields from the User Interface.

You can use Powershell (server side) to set the additional lookup fields by explicitely adding a field link object to the target list content type.

# Get the target list content type
$ListCTs = $targetsite.Lists["targetlisttitle"].ContentTypes
# assuming the content type is the first one
$ListCTs[0].FieldLinks | ft DisplayName
# This displays the current fields included in content type, you may note some difference from what can be seen in the UI.
# search for the field you want to include in the list content type
$targetsite.Fields | ? { $_.Title -match "yourmatch" }
# create a field link
$TargetField = $targetsite.Fields["targetfieldtitle"]
$TargetFieldLink = new-object Microsoft.SharePoint.SPFieldLink $TargetFieldLink
$ListCTs[0].FieldLinks.Add($TargetFieldLink)
$ListCTs[0].Update()
# check the field link has been added
$ListCTs[0].FieldLinks | ft DisplayName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment