sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

JSON Formatting List issue with fields added after initial creation.

Open justinlwilson opened this issue 7 years ago • 4 comments

Category

  • [ ] Question
  • [ ] Typo
  • [x] Bug
  • [ ] Additional article idea

Expected or Desired Behavior

When adding a new Person field to an existing list - I expect to be able to utilize the new field in the JSON Format View.

Observed Behavior

Attributes to the Person object in a LIST is unavailable if the Person object is added to the list after it's initial creation.

Steps to Reproduce

Step One Create a list with the following fields: Title (Text), Description (Text), AssignedTo (Person). Create a record.

Step Two Use the following JSON to format the list.

{
  "schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
  "hideSelection": true,
  "hideColumnHeader": true,
  "rowFormatter": {
    "elmType": "div",
    "attributes": {
      "class": "sp-row-card"
    },
    "children": [
      {
        "elmType": "div",
        "style": {
          "text-align": "left"
        },
        "children": [
          {
            "elmType": "div",
            "attributes": {
              "class": "sp-row-title"
            },
            "txtContent": "[$Title]"
          },
          {
            "elmType": "div",
            "attributes": {
              "class": "sp-row-listPadding"
            },
            "txtContent": "[$Description]"
          },
          {
            "elmType": "div",
            "attributes": {
              "class": "sp-row-listPadding"
            },
            "children": [
              {
                "elmType": "span",
                "attributes": {
                  "class": "sp-row-listPadding"
                },
                "txtContent": "Assigned To: "
              },
              {
                "elmType": "span",
                "attributes": {
                  "class": "sp-row-listPadding"
                },
                "txtContent": "[$AssignedTo.title]"
              }
            ]
          }
        ]
      }
    ]
  }
}

Step Three Enter quick edit and add a new field: QCby (Person) and assign someone to the record created in step one.

Step Four Change the JSON formatting to the following:

{
    "schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
    "hideSelection": true,
    "hideColumnHeader": true,
    "rowFormatter": {
      "elmType": "div",
      "attributes": {
        "class": "sp-row-card"
      },
      "children": [
        {
          "elmType": "div",
          "style": {
            "text-align": "left"
          },
          "children": [
            {
              "elmType": "div",
              "attributes": {
                "class": "sp-row-title"
              },
              "txtContent": "[$Title]"
            },
            {
              "elmType": "div",
              "attributes": {
                "class": "sp-row-listPadding"
              },
              "txtContent": "[$Description]"
            },
            {
              "elmType": "div",
              "attributes": {
                "class": "sp-row-listPadding"
              },
              "children": [
                {
                  "elmType": "span",
                  "attributes": {
                    "class": "sp-row-listPadding"
                  },
                  "txtContent": "Assigned To: "
                },
                {
                  "elmType": "span",
                  "attributes": {
                    "class": "sp-row-listPadding"
                  },
                  "txtContent": "[$AssignedTo.title]"
                }
              ]
            },
            {
                "elmType": "div",
                "attributes": {
                  "class": "sp-row-listPadding"
                },
                "children": [
                  {
                    "elmType": "span",
                    "attributes": {
                      "class": "sp-row-listPadding"
                    },
                    "txtContent": "Quality Control: "
                  },
                  {
                    "elmType": "span",
                    "attributes": {
                      "class": "sp-row-listPadding"
                    },
                    "txtContent": "[$QCBy.title]"
                  }
                ]
              }
          ]
        }
      ]
    }
  }

justinlwilson avatar Mar 08 '19 13:03 justinlwilson

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

msft-github-bot avatar Mar 08 '19 13:03 msft-github-bot

Thanks for reporting this issue. The issue here is that the UX that created new columns in quick edit was still in classic and the classic code in quick edit code path created the column with a "non-readable" internal name. That is, even though you chose "QCBy" as your column "name", the code used that as "Title" or "display name" of the new field, yet the "internal Name", which custom formatter uses to reference to the field, is not remotely close to QCBY, it is "ws3n" in my test case and it might be something completely different for you. See the attached JSON schema markup below. We'll modernize the quick edit UX in the future so this might get better in the future. In the mean time, you're not blocked and you have plenty of options to get it working given the limitation, To workaround the issue, you can

  1. create the field in more traditional List Setting UX, which will honor the field internalName better aligned with display name.
  2. You can find the internal Name of the field yourself. That can be done with standard REST/JSON, or you can simply look at the pagemarkup, and the JSON at the bottom of the page might contain the following, from QCBy displayName you can get the internalName.

{"Name": "ws3n",

  | "FieldType": "User",   | "RealFieldName": "ws3n",   | "DisplayName": "QCBy",   | "ID": "a3f5a2ae-8eb6-4155-8b47-bf29890d4b37",   | "StaticName": "ws3n",   | "role": "User",   | "ariaLabel": "QCBy",

rchendev avatar Apr 20 '19 18:04 rchendev

I'm able to confirm on my end.

That's interesting. Thanks for the workaround. I hope that future updates can rectify the issue. The multiple perspective methods for creating the same items is tiresome. I'll just be sure to pull all the details through the REST endpoints to verify all the names/values. Assume nothing.

justinlwilson avatar Apr 24 '19 14:04 justinlwilson

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

msft-github-bot avatar Jan 25 '20 00:01 msft-github-bot