PnP icon indicating copy to clipboard operation
PnP copied to clipboard

SetShowInDisplayForm not working

Open albegut opened this issue 4 years ago • 2 comments

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

  • PnP PowerShell - https://github.com/OfficeDev/PnP-PowerShell

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 <SiteUrl> $field = Get-PnPField -Identity <FieldName> -List <ListName> $field.SetShowInDisplayForm($false) $field.Update() $field.Context.ExecuteQuery()

Thanks!

albegut avatar Mar 27 '20 11:03 albegut

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()

kachihro avatar Apr 13 '20 01:04 kachihro

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

phillipharding avatar Apr 13 '20 23:04 phillipharding