SharePoint Online: How to Change Required Field Settings in a List or Library?

Requirement: Set required fields in SharePoint Online list or document library.

How to Set Required Fields in SharePoint Online?
Required fields setting in SharePoint Online lists and libraries help to ensure that users enter certain information when saving items or uploading files. You can configure any field as a required field in SharePoint - or change a field to not be required. By default, Certain fields are marked as "Required" in SharePoint. E.g. For custom lists - Title field is required.

You can mark a field as required either while creating a new column or editing existing column in SharePoint Online list or document library by settings the configuration "Require that this column contains information" to "Yes".
sharepoint online document library required field

You can also change required field configuration from list or library settings:
  • Navigate to the list or library where you would like to mark a field as required.
  • Click on the settings gear icon in the top right of the page and select list settings.
  • In the List Settings page, Scroll down to the Columns section and Click on a Column that you would like to make required.
  • Scroll down to the Additional Column Settings and to select "Yes" to make the field required or "No" to make it optional.
    sharepoint online required field
  • Select OK to save your changes.
When users tries to saved a item or file without filling in the required field, they'll see an error message "You can't leave this blank".
make a field required in sharepoint online
If the default value is set for any field, such as Choice fields - Required field validation won't trigger as the default value will automatically apply. When you mark a field as required in SharePoint Online document libraries, and bulk upload files either by Drag-and-drop/Explorer view/Menu, The documents will be checked out automatically and not available for other users, until you populate the required fields and check-in documents.

However, In modern libraries, this behavior is bit different: Documents will not be checked-out (as long as the "Require Check Out" in the Versioning settings is set to "No") when a mandatory field value is missing, but you'll see a message "Required Info" on those items.
document library required field in sharepoint online

PowerShell to Change Required Fields Settings in SharePoint Online:
We can turn required field settings for all fields in a SharePoint List or library to either ON or OFF using PowerShell as:
#Set Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/PMO"
$ListName = "Projects"

#Connect to SharePoint Online
Connect-PnPOnline -Url $SiteURL -UseWebLogin

#Get the List
$List = Get-PnPList -Identity $ListName

#Get all Required Fields - Exclude system fields
$RequiredFields = Get-PnPField -List $List | Where { $_.Required -eq $true -and $_.Title -ne "Name" -and $_.ReadOnlyField -eq $false -and $_.Hidden -eq $false -and $_.InternalName -ne  "ContentType" -and $_.InternalName -ne  "Attachments"}

ForEach($Field in $RequiredFields)
{
    #Set Required Field Flag to False
    $Field.Required = $False
    $Field.Update()
    Invoke-PnPQuery
    Write-Host "Required Field Settings updated for $($Field.Title)"
}
This script removes require field flag from all columns. You can set the flag as $True and change the where condition to do the reverse as well. Here is my another post on setting a field as required or not-required using PowerShell: How to Make a Field Required in SharePoint Online using PowerShell?

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.