Question

Hope someone will be able to help me on this.

I'm looking for a way to disable (having it read only) a List column using some JSON formatting.

I know I can do it using additional calculated columns but I don't want to do this cause I have several columns and that will be too much.

Few years ago, I saw someone doing it with JSON code, something like:

{
  "elmType": "div",
  "txtContent": "@currentField"
}

I know there's something missing in there but I don't remember what.

Does anyone have an idea how to do this ?

Was it helpful?

Solution

As a workaround,you could use pnp powershell to set column read only.

$username = "amos@contoso.onmicrosoft.com"
$password = "Password"
$cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $(convertto-securestring $Password -asplaintext -force)

Connect-PnPOnline -Url https://contoso.sharepoint.com/sites/dev -Credentials $cred
 
# Get Context
$clientContext = Get-PnPContext
 
# -List: The list object or name of the list
# -Identity: The field object or name
$targetField = Get-PnPField -List "test_test" -Identity "unClickable"
 
# Make list column required
$targetField.ReadOnlyField = 1   
   
$targetField.Update()
 
$clientContext.ExecuteQuery()
 
Disconnect-PnPOnline
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top