Skip to main content

I'm trying to change the setting of a column to make it not a required field. This is the code I'm using:

$site = new-object Microsoft.SharePoint.SPSite("abc.com") $web = $site.OpenWeb()

$MyContentType=$web.ContentTypes["ContentType"] $MyField=$MyContentType.Fields | Where {$_.Id -eq $web.Fields["Column"].id} $MyContentType.FieldLinks[$MyField.Id].Required=$False

$MyContentType.Update()

$site = new-object Microsoft.SharePoint.SPSite("abc.com")
$web = $site.OpenWeb()

$MyContentType=$web.ContentTypes["ContentType"]
$MyField=$MyContentType.Fields | Where {$_.Id -eq $web.Fields["Column"].id}
$MyContentType.FieldLinks[$MyField.Id].Required=$False 

$MyContentType.Update()

But this is giving error that $MyContentType.FieldLinks$MyContentType.FieldLinks is NULLNULL. How can I successfully execute my powershellPowerShell script?

I'm trying to change the setting of a column to make it not a required field. This is the code I'm using:

$site = new-object Microsoft.SharePoint.SPSite("abc.com") $web = $site.OpenWeb()

$MyContentType=$web.ContentTypes["ContentType"] $MyField=$MyContentType.Fields | Where {$_.Id -eq $web.Fields["Column"].id} $MyContentType.FieldLinks[$MyField.Id].Required=$False

$MyContentType.Update()

But this is giving error that $MyContentType.FieldLinks is NULL. How can I successfully execute my powershell?

I'm trying to change the setting of a column to make it not a required field. This is the code I'm using:

$site = new-object Microsoft.SharePoint.SPSite("abc.com")
$web = $site.OpenWeb()

$MyContentType=$web.ContentTypes["ContentType"]
$MyField=$MyContentType.Fields | Where {$_.Id -eq $web.Fields["Column"].id}
$MyContentType.FieldLinks[$MyField.Id].Required=$False 

$MyContentType.Update()

But this is giving error that $MyContentType.FieldLinks is NULL. How can I successfully execute my PowerShell script?

Source Link
kaz
  • 167
  • 1
  • 5
  • 14

Changing Column Settings for a Content Type using Powershell

I'm trying to change the setting of a column to make it not a required field. This is the code I'm using:

$site = new-object Microsoft.SharePoint.SPSite("abc.com") $web = $site.OpenWeb()

$MyContentType=$web.ContentTypes["ContentType"] $MyField=$MyContentType.Fields | Where {$_.Id -eq $web.Fields["Column"].id} $MyContentType.FieldLinks[$MyField.Id].Required=$False

$MyContentType.Update()

But this is giving error that $MyContentType.FieldLinks is NULL. How can I successfully execute my powershell?