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', '')" },

1
  • Your example is not complete, so it's hard to tell what's wrong. Commented Oct 23, 2018 at 14:57

2 Answers 2

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"
    }
  ]
}
0
{
   "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
   "elmType": "div",
  
  "txtContent": "=floor(@currentField) + '%'"
   
}

Problem

Solution

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.