i am working on an online classic team site, and i have a site column named "AutomaticallyCreated" which is set to hidden inside create,edit and display form. now i want to show it inside the Edit and display forms, so i run the following powershell script :-
$User = "admin@****.onmicrosoft.com"
$SiteURL = "https://***.sharepoint.com/sites/**** #enter site collection url"
#Add references to SharePoint client assemblies and authenticate to Office 365 site – required for CSOM
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
$Password = Read-Host -Prompt "enterpassword" -AsSecureString
$Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Password)
#Bind to site collection
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($User,$Password)
$Context.Credentials = $Creds
$fieldTitle = "AutomaticallyCreated"
$customfield = $Context.Site.RootWeb.Fields.GetByInternalNameOrTitle($fieldTitle)
$customfield.ShowInEditForm($true)
$customfield.ShowInDisplayForm($true)
$customfield.UpdateAndPushChanges($true)
$Context.ExecuteQuery()
but i got these exceptions:-
Method invocation failed because [Microsoft.SharePoint.Client.Field] doesn't
contain a method named 'ShowInEditForm'.
At line:1 char:1
+ $customfield.ShowInEditForm($true)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
Method invocation failed because [Microsoft.SharePoint.Client.Field] doesn't
contain a method named 'ShowInDisplayForm'.
At line:1 char:1
+ $customfield.ShowInDisplayForm($true)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
so can anyone advice on this please? the fields should have methods named ShowInEditForm
& ShowInDisplayForm
..