0

If I add an external data column to a SharePoint list and chooses to add one or more secondary fields, the secondary fields happily appear in list views but not in list forms. How do I make the secondary fields appear in the list forms as well?

1 Answer 1

0

SharePoint provisions field definitions for fields specified in the SecondaryFieldWssNames attribute as read-only fields (ReadOnly="TRUE"), and does not add any of the ShowIn...Form attributes to the field schema XML.

This effectively makes the secondary fields invisible in the list forms.

One can use PowerShell to add the necessary ShowIn...Form attributes to the field schema XML of a secondary field that should become visible in a list form.

Here's a sample code snippet illustrating the idea by using Office PnP commandlets:

[Microsoft.SharePoint.Client.ClientContext]$ctx = (Get-PnpConnection | Select-Object -ExpandProperty 'Context')
$list = Get-PnPList -Identity ExternalColumnTest

[Microsoft.SharePoint.Client.Field]$projectAccountField = Get-PnPField -List $list -Identity 'Project_x003a__x0020_Account'
$ctx.Load($projectAccountField)  
$ctx.ExecuteQuery()

[XML]$accountFieldSchema = $projectAccountField.SchemaXml
$accountFieldSchema.Field.setattribute('ShowInDisplayForm','TRUE')
$projectAccountField.SchemaXml = $accountFieldSchema.OuterXml
$projectAccountField.Update()

$ctx.ExecuteQuery()

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.