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?

Was it helpful?

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

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top