Question

I have a field which was created at the list level inside my online SharePoint site, and i want to hide it from the create form, so i run the following PnP code:-

PS C:\WINDOWS\system32> Connect-PnPOnline -Url https://****.sharepoint.com/sites/***
PS C:\WINDOWS\system32> $fieldTitle = "ClosureSummary"
PS C:\WINDOWS\system32> $list2 = Get-PnPList -Identity Lists/ProjectUpdateSystem
PS C:\WINDOWS\system32> $customfield = $list2.Fields.GetByInternalNameOrTitle($fieldTitle)
PS C:\WINDOWS\system32> $customfield.SetShowInNewForm($false)
PS C:\WINDOWS\system32> $Context.ExecuteQuery()
PS C:\WINDOWS\system32> $customfield.UpdateAndPushChanges($true)
PS C:\WINDOWS\system32> $Context.ExecuteQuery()

Now i did not get any error but the field is still showing inside the list create form, any advice?

Était-ce utile?

La solution

This worked for me. Used field.Context.ExecuteQuery()

$list = Get-PnPList -Identity Lists/Contact
$customfield=Get-PnPField -List $list -Identity "Title"
$customfield.SetShowInNewForm($false)
$customfield.UpdateAndPushChanges($true)

$customfield.Context.ExecuteQuery()

Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top