0

I have been working with customizing SharePoint Columns and using the pre defined Microsoft list view edits.

The trouble I am experiencing is that the formatting is working, however it is adding 50 decimal places to the end of the value instead of rounding to the nearest whole number as defined in the columns settings.

If anyone has ever worked with these methods before I would more than appreciate any offered input.

Below is the part of the formatting code I use to define the formatting. It's checking the days elapsed in a "days In progress" column and Returning a warning format if the days in progress are > 10.

{ "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json", "debugMode": true, "elmType": "div", "attributes": { "class": "= if (@currentField > 10,'sp-field-severity--blocked', '')" },

  • Your example is not complete, so it's hard to tell what's wrong. – Mike Smith - MCT - MVP Oct 23 '18 at 14:57
0

The @currentField gets the actual value of field. It ignores the “Number of decimal places” list setting.

To work around this issue, we can use a calculated field with the following formula to round the "days In progress" number to a specified number of digits.

=ROUND([days In progress],0)

Then, using the JSON formats the calculated field.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "debugMode": true,
  "elmType": "div",
  "attributes": {
    "class": "=if(@currentField>10,'sp-field-severity--blocked', '')"
  },
  "children": [
    {
      "elmType": "span",
      "style": {
        "display": "inline-block",
        "padding": "0 4px"
      }
    },
    {
      "elmType": "span",
      "txtContent": "@currentField"
    }
  ]
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.