1

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 ?

13
  • What do you mean by disabling list column? You don't want users to edit this field or is it link type column and you don't want your users to click on it? what is the data type of your column? Commented Jul 6, 2020 at 15:38
  • List formatting will only affect the display and has no effect on the writability (or even the display on the form) of fields Commented Jul 6, 2020 at 15:39
  • @theChrisKent: I understand what you say but i know the guy did it, he changed something in the code sample up there. and the field became read only. i just don't remember who the guy was and i don't know anyone anymore in that company. Commented Jul 6, 2020 at 15:47
  • @GaneshSanap: My columns are text. I mean having the column like "read only" . As if you were trying to type into a calculated field. i don't want the users to edit the fields. I know the downside was the fields were still editable in the form but back then, i removed them from the form. Commented Jul 6, 2020 at 15:47
  • 1
    Hi @theChrisKent, thanks for your answer. I watched this video before creating the post. Well ok then :-( that means i'll have to create additional columns. thanks for your time ! have a great day Commented Jul 7, 2020 at 6:10

1 Answer 1

0

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

$username = "[email protected]" $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 
1
  • Hi @Amos_MSFT, Thanks a lot for your answer. This is great ! but... I'm working for a pretty big financial institution and our laptops are restricted for lots of things. I won't be able to do this. I finally used calculated fields to do the trick, i don't really like it but...well. Anyway, i'll mark your solution as accepted in case it's of any help for someone else...or for me in the future. Thanks again !! Commented Jul 7, 2020 at 19:24

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.