pnp / PnP

SharePoint / Office 365 Developer Patterns and Practices - Archived older solutions. Please see https://aka.ms/m365pnp for updated guidance
https://aka.ms/m365pnp
Other
1.9k stars 3.31k forks source link

SetShowInDisplayForm not working #1900

Open albegut opened 4 years ago

albegut commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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