0

Using SPO, I can get JSON column formatting to work on my library. However, any formatting I apply to the "Shared With" column works in preview mode but does not save with the view.

I think this is because it's a "special" column that the library is generating for the subfolders, rather than a normal library/list column.

Has anyone managed to apply column formatting to this column and get it to persist? Here's the code I'm using, which works beautifully but doesn't stick. I've also tried simpler code that works on other columns but not on the "Shared With" column.

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "style": {
        "min-height": "1.5em",
        "flex-direction": "column",
        "align-items": "start",
        "padding-top": "4px",
        "padding-bottom": "4px"
    },
    "children": [
        {
            "elmType": "div",
            "txtContent": "=length(@currentField)",
            "style": {
                "border-radius": "1.5em",
                "height": "1.5em",
                "min-width": "1.5em",
                "color": "white",
                "text-align": "center",
                "position": "absolute",
                "top": "4px",
                "right": "1em",
                "background-color": "=if(length(@currentField) == 1, '#3c3', '#33c'"
            }
        },
        {
            "elmType": "div",
            "forEach": "person in @currentField",
            "style": {
                "justify-content": "center"
            },
            "children": [
                {
                    "elmType": "div",
                    "style": {
                        "display": "flex",
                        "flex-direction": "row",
                        "justify-content": "center"
                    },
                    "children": [
                        {
                            "elmType": "a",
                            "attributes": {
                                "href": "[$person.email]"
                            },
                            "style": {
                                "margin-left": "0.5em"
                            },
                            "children": [
                                {
                                    "elmType": "div",
                                    "txtContent": "[$person.title]",
                                    "style": {
                                        "font-size": "1.2em"
                                    }
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}

1 Answer 1

1

I can reproduce the same issue on my SharePoint Online library. I think column formatting is not supported for this column yet (Even when it is of type Person or Group).
I tried applying the JSON code from both library view and column settings but it not accepting the JSON while saving)

You can check the supported columns from below documentation:
Use column formatting to customize SharePoint - Supported column types.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.