0

enter image description here

Hi there,

I am relatively new to using SharePoint as well as JSON and as mentioned in the subject, I am having issues in trying to reference the Version column (set by the approval status).

What I hope to achieve is such that if the "version" number is the same as the "version flow" number, a conditional formatting would be set to show a green background and red if the version flow number is less than the version number.

I have hard coded the values of 13 just to see if I could get the colours to appear. Whenever I try to reference [$Version], the values in version flow would disappear. Help on the matter would be greatly appreciated!

I have attached my current code applied to th 'Version Flow' column as conditional formatting.

{
  "elmType": "div",
  "txtContent": "@currentField",
  "attributes": {},
  "style": {
    "background-color": {
      "operator": "?",
      "operands": [
        {
          "operator": ">=",
          "operands": [
            "@currentField",
            "13.0"
          ]
        },
        "#98FB98",
        {
          "operator": "?",
          "operands": [
            {
              "operator": "<",
              "operands": [
                "@currentField",
                "13.0"
              ]
            },
            "#FF6A6A",
            ""
          ]
        }
      ]
    }
  },
  "customRowAction": {},
  "children": []
}
7
  • Also, you are saying What I hope to achieve is such that if the "version" number is the same as the "version flow" number and you are checking the condition for greater than or equal to in your first condition. check this. Commented Sep 3, 2019 at 8:58
  • Thanks for pointing this out. It's actually another issue that I have yet to resolve. Strangely when say for example, version = 15.1 and version flow = 15.1, when I set the condtion operator to "==", the condition result is false. Any idea why> =
    – cyw_bat
    Commented Sep 4, 2019 at 1:31
  • What is the data type of Version flow field? Commented Sep 4, 2019 at 2:20
  • I just found my error thanks to your question! Version flow was originally of number type. I changed it to string and now it works.
    – cyw_bat
    Commented Sep 5, 2019 at 3:05
  • Glad to hear that it worked for you. Commented Sep 5, 2019 at 3:56

1 Answer 1

1

Instead of using [$Version], use [$_UIVersionString].

So, your code should be something like below:

{
  "elmType": "div",
  "txtContent": "@currentField",
  "attributes": {},
  "style": {
    "background-color": {
      "operator": "?",
      "operands": [
        {
          "operator": ">=",
          "operands": [
            "@currentField",
            [$_UIVersionString]
          ]
        },
        "#98FB98",
        {
          "operator": "?",
          "operands": [
            {
              "operator": "<",
              "operands": [
                "@currentField",
                [$_UIVersionString]
              ]
            },
            "#FF6A6A",
            ""
          ]
        }
      ]
    }
  },
  "customRowAction": {},
  "children": []
}

Note: Version is a Single line of text field.

2
  • Try above code and let me know if it works or not. Commented Sep 3, 2019 at 8:54
  • Works like a charm! Thank you so much Ganesh.
    – cyw_bat
    Commented Sep 4, 2019 at 0:02

Your Answer

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

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