Skip to content
This repository has been archived by the owner on Aug 24, 2021. It is now read-only.

SetShowInDisplayForm not working #1900

Open
albegut opened this issue Mar 27, 2020 · 2 comments
Open

SetShowInDisplayForm not working #1900

albegut opened this issue Mar 27, 2020 · 2 comments

Comments

@albegut
Copy link

albegut commented Mar 27, 2020

####Which PnP repository should you use to report the issue?####

Category

[x] Bug
[ ] Enhancement

Environment

[x] Office 365 / SharePoint Online
[ ] SharePoint 2016
[ ] SharePoint 2013

Expected or Desired Behavior

After using $field.SetShowInDisplayForm($false) the field should no longer be displayed in the Dispform.aspx form

Observed Behavior

The field is still displayed on the form. In order to hide it, it is necessary to use the SetShowInEditForm method, hiding it in the dispform and in the editform.
It is not possible to hide a field in the dispform only by powershell.

Steps to Reproduce

Connect-PnPOnline -Url
$field = Get-PnPField -Identity -List $field.SetShowInDisplayForm($false)
$field.Update()
$field.Context.ExecuteQuery()

Thanks!

@kachihro
Copy link

Just tried this also - with a slightly different command for '$field'
$field = Get-PnPField -List "Demo list" -Identity "TestColumn"

I tired the methods for 'SetShowInDisplayForm' and 'SetShowInEditForm' - no impact. Perhaps they are only for CLASSIC mode. Not modern. Even setting a field to HIDDEN or READONLY - has no impact.

But - I was able to set the 'SCHEMAXML' - and it worked (hid the field in edit or display mode)

NOTE - I think you also have to set 'Hidden=False' - for it to work...

$field.SchemaXml = '<Field Type="Text" DisplayName="BBB" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" MaxLength="255" ID="{67ec9afa-6a3b-4447-acf2-6dc4306a01ff}" SourceID="{7c9325af-d58f-400d-b825-b3e91da06da0}" StaticName="BBB" Name="BBB" ColName="nvarchar5" RowOrdinal="0" ShowInDisplayForm="FALSE" Hidden="FALSE" />'

$field.Update()
$list.Update()

@phillipharding
Copy link

This is by design on the SharePoint side, with new modern list forms the Display form is actually an Edit form also.
These settings still work if the list is placed in Classic mode

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants