1

I have a SharePoint Library with a choice column ("yes" and no" values) in which I want the user to be able to modify without entering Grid View. The idea is for the user to create a new doc set, upload documents, then update this field = Yes to trigger an approval flow. The Json I entered looks correct on the surface, but when I click the field, the value disappears, rather than allowing me to select either "Yes" or "No".

How it looks before clicking on it: enter image description here

How it looks after clicking on the field: enter image description here

Here is my JSON code:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "inlineEditField": "@currentField",
  "style": {
    "flex-wrap": "wrap",
    "display": "flex"
  },
  "children": [
    {
      "elmType": "div",
      "style": {
        "box-sizing": "border-box",
        "padding": "4px 8px 5px 8px",
        "overflow": "hidden",
        "text-overflow": "ellipsis",
        "display": "flex",
        "border-radius": "16px",
        "height": "24px",
        "align-items": "center",
        "white-space": "nowrap",
        "margin": "4px 4px 4px 4px"
      },
      "attributes": {
        "class": {
          "operator": ":",
          "operands": [
            {
              "operator": "==",
              "operands": [
                "@currentField",
                "Yes"
              ]
            },
            "sp-css-backgroundColor-BgMintGreen sp-field-fontSizeSmall sp-css-color-MintGreenFont",
            {
              "operator": ":",
              "operands": [
                {
                  "operator": "==",
                  "operands": [
                    "@currentField",
                    "No"
                  ]
                },
                "sp-css-backgroundColor-BgDustRose sp-css-borderColor-DustRoseFont sp-field-fontSizeSmall sp-css-color-DustRoseFont",
                {
                  "operator": ":",
                  "operands": [
                    {
                      "operator": "==",
                      "operands": [
                        "@currentField",
                        ""
                      ]
                    },
                    "",
                    "sp-field-borderAllRegular sp-field-borderAllSolid sp-css-borderColor-neutralSecondary"
                  ]
                }
              ]
            }
          ]
        }
      },
      "txtContent": "@currentField"
    }
  ]
}

Any help would be greatly appreciated. I had this field as a Yes/No field initially, but I want the user's experience to be a Dropdown, rather than a Checkbox. And I couldn't figure out a way to present that in w Y/N column.

1 Answer 1

2

You could remove the existing formatting and use the following (make sure you use the correct field name). Maybe @currentField is not allowed for this kind of JSON.

 //In the example below, [ReadyForApproval] is a Choice column
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "inlineEditField": "[$ReadyForApproval]",
  "txtContent": "[$ReadyForApproval]"
}

See more examples on JSON formatting at Advanced formatting concepts

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.