1

I've tried inserting this nice JSON Icon Progress Bar in my list view (thanks to this so useful page) but it does not display.

As I am in a view formatting, I have changed the fields @currentField by $Progression wich is the internal name of my "Number" column (I've double checked the internal name) under line 191.

As I can't find the solution despite long searches, could someone help me? Thank you.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
  "hideSelection": true,
  "hideColumnHeader": true,
  "rowFormatter": {
    "elmType": "div",
    "_comment_": "MAIN DIV",
    "attributes": {
      "class": "ms-bgColor-neutralLighter"
    },
    "style": {
      "display": "flex",
      "flex-wrap": "wrap",
      "align-items": "stretch",
      "justify-content": "flex-start",
      "flex-direction": "row",
      "padding": "20px",
      "margin-bottom": "16px",
      "max-width": "1200px",
      "border-radius": "8px"
    },
    "children": [
      {
        "elmType": "div",
        "__comment": "GAUCHE",
        "style": {
          "flex-grow": "1",
          "display": "inline-block",
          "flex-direction": "column",
          "flex-wrap": "nowrap",
          "align-items": "left",
          "max-width": "200px",
          "min-width": "100px",
          "margin-right": "95px",
          "text-align": "left"
        },
        "children": [
          {
            "elmType": "span",
            "txtContent": "=[$field_0]",
            "style": {
              "font-weight": "bold",
              "font-size": "16px",
              "color": "#FFFFFF",
              "background-color": {
                "operator": ":",
                "operands": [
                  {
                    "operator": "==",
                    "operands": [
                      "[$field_0]",
                      "One TSC"
                    ]
                  },
                  "#FF7700",
                  {
                    "operator": ":",
                    "operands": [
                      {
                        "operator": "==",
                        "operands": [
                          "[$field_0]",
                          "Make or Buy"
                        ]
                      },
                      "#50BE87",
                      {
                        "operator": ":",
                        "operands": [
                          {
                            "operator": "==",
                            "operands": [
                              "[$field_0]",
                              "Performance"
                            ]
                          },
                          "#4BB4E6",
                          {
                            "operator": ":",
                            "operands": [
                              {
                                "operator": "==",
                                "operands": [
                                  "[$field_0]",
                                  "Formation - Consignes"
                                ]
                              },
                              " #FFB4E6",
                              {
                                "operator": ":",
                                "operands": [
                                  {
                                    "operator": "==",
                                    "operands": [
                                      "[$field_0]",
                                      "Poste de travail"
                                    ]
                                  },
                                  "#FFD200",
                                  "#800080"
                                ]
                              }
                            ]
                          }
                        ]
                      }
                    ]
                  }
                ]
              },
              "border-radius": "20px",
              "padding": "5px 10px"
            }
          },
          {
            "elmType": "div",
            "txtContent": "=[$Title]",
            "style": {
              "font-weight": "bold",
              "font-size": "16px",
              "color": {
                "operator": ":",
                "operands": [
                  {
                    "operator": "==",
                    "operands": [
                      "[$background-color]",
                      "#FF7700"
                    ]
                  },
                  "#FF7700",
                  "#000000"
                ]
              },
              "white-space": "normal",
              "padding-top": "20px",
              "padding-left": "1px"
            }
          }
        ]
      },
      {
        "elmType": "div",
        "__comment": "MILIEU",
        "style": {
          "flex-grow": "1",
          "display": "flex",
          "flex-direction": "column",
          "flex-wrap": "nowrap",
          "align-items": "left",
          "max-width": "400px",
          "min-width": "205px"
        },
        "children": [
          {
            "elmType": "div",
            "_comment": " DIV_ACTION",
            "style": {
              "display": "block"
            },
            "children": [
              {
                "elmType": "span",
                "attributes": {
                  "iconName": "BullseyeTarget"
                },
                "style": {
                  "font-size": "14px",
                  "padding-right": "5px",
                  "color": "grey"
                }
              },
              {
                "elmType": "span",
                "txtContent": "Action",
                "style": {
                  "font-size": "14px",
                  "color": "grey"
                }
              },
              {
                "elmType": "span",
                "txtContent": "=[$field_2]",
                "style": {
                  "font-size": "14px",
                  "font-weight": "bold",
                  "white-space": "normal",
                  "word-break": "break-word",
                  "display": "-webkit-box",
                  "text-overflow": "ellipsis",
                  "overflow": "hidden",
                  "word-wrap": "break-word"
                }
              }
            ]
          },
          {
            "elmType": "div",
            "_comment": "DIV_DELAI",
            "attributes": {
              "class": "sp-card-displayColumnContainer"
            },
            "children": [
              {
                "elmType": "div",
                "attributes": {
                  "iconName": "Calendar"
                },
                "style": {
                  "font-size": "14px",
                  "padding-right": "5px",
                  "color": "grey",
                  "padding-top": "20px"
                }
              },
              {
                "elmType": "span",
                "txtContent": "Délai",
                "style": {
                  "color": "grey",
                  "font-size": "14px"
                }
              },
              {
                "elmType": "p",
                "attributes": {
                  "title": "[$field_3]",
                  "class": "ms-fontColor-neutralPrimary sp-card-content  sp-card-multiline"
                },
                "txtContent": "=if ([$field_3] == '', '–', [$field_3])",
                "style": {
                  "font-weight": "bold",
                  "font-size": "14px"
                }
              },
              {
                "elmType": "div",
                "_comment": "DIV_PROGRESSION",
                "style": {
                  "display": "block"
                },
                "children": [
                  {
                    "elmType": "span",
                    "attributes": {
                      "iconName": "Financial"
                    },
                    "style": {
                      "font-size": "14px",
                      "padding-right": "5px",
                      "color": "grey"
                    }
                  },
                  {
                    "elmType": "span",
                    "txtContent": "Avancement",
                    "style": {
                      "font-size": "14px",
                      "color": "grey"
                    }
                  },
                  {
                    "elmType": "div",
                    "style": {
                      "font-size": "16px"
                    },
                    "children": [
                      {
                        "elmType": "span",
                        "attributes": {
                          "title": "0-20%",
                          "iconName": "=if($Progression < 1, 'CircleRing', 'SkypeCircleCheck')",
                          "class": "='ms-fontColor-' + if($Progression == 1, 'green', if($Progression > 1, 'greenLight', 'neutralLight'))"
                        },
                        "style": {
                          "padding": "0 2px"
                        }
                      },
                      {
                        "elmType": "span",
                        "attributes": {
                          "title": "Step 2",
                          "iconName": "=if($Progression < 2, 'CircleRing', 'SkypeCircleCheck')"
                        },
                        "style": {
                          "padding": "0 2px"
                        }
                      },
                      {
                        "elmType": "span",
                        "attributes": {
                          "title": "Step 3",
                          "iconName": "=if($Progression < 3, 'CircleRing', 'SkypeCircleCheck')",
                          "class": "='ms-fontColor-' + if($Progression == 3, 'green', if($Progression > 3, 'greenLight', 'neutralLight'))"
                        },
                        "style": {
                          "padding": "0 2px"
                        }
                      },
                      {
                        "elmType": "span",
                        "attributes": {
                          "title": "Step 4",
                          "iconName": "=if($Progression < 4, 'CircleRing', 'SkypeCircleCheck')",
                          "class": "='ms-fontColor-' + if($Progression == 4, 'green', if($Progression > 4, 'greenLight', 'neutralLight'))"
                        },
                        "style": {
                          "padding": "0 2px"
                        }
                      },
                      {
                        "elmType": "span",
                        "attributes": {
                          "title": "Step 5",
                          "iconName": "=if($Progression < 5, 'CircleRing', 'SkypeCircleCheck')",
                          "class": "='ms-fontColor-' + if($Progression == 5, 'green', if($Progression > 5, 'greenLight', 'neutralLight'))"
                        },
                        "style": {
                          "padding": "0 2px"
                        }
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "elmType": "div",
        "__comment": "DROITE",
        "style": {
          "flex-grow": "1",
          "display": "flex",
          "flex-direction": "column",
          "flex-wrap": "nowrap",
          "align-items": "left",
          "max-width": "300px",
          "min-width": "205px"
        },
        "children": [
          {
            "elmType": "div",
            "_comment": " DIV_PORTEUR",
            "style": {
              "display": "block"
            },
            "children": [
              {
                "elmType": "span",
                "attributes": {
                  "iconName": "Telemarketer"
                },
                "style": {
                  "font-size": "14px",
                  "padding-right": "5px",
                  "color": "grey"
                }
              },
              {
                "elmType": "span",
                "txtContent": "Porteur",
                "style": {
                  "font-size": "14px",
                  "color": "grey"
                }
              },
              {
                "elmType": "span",
                "txtContent": "=[$field_2]",
                "style": {
                  "font-size": "14px",
                  "font-weight": "bold",
                  "white-space": "normal",
                  "word-break": "break-word",
                  "display": "-webkit-box",
                  "text-overflow": "ellipsis",
                  "overflow": "hidden",
                  "word-wrap": "break-word"
                }
              }
            ]
          },
          {
            "elmType": "div",
            "_comment": "DIV_CONTRIBUTEUR",
            "attributes": {
              "class": "sp-card-displayColumnContainer"
            },
            "children": [
              {
                "elmType": "div",
                "attributes": {
                  "iconName": "Touch"
                },
                "style": {
                  "font-size": "14px",
                  "padding-right": "5px",
                  "color": "grey",
                  "padding-top": "20px"
                }
              },
              {
                "elmType": "span",
                "txtContent": "Contributeur(s)",
                "style": {
                  "color": "grey",
                  "font-size": "14px",
                  "padding-top": "20px"
                }
              },
              {
                "elmType": "p",
                "attributes": {
                  "title": "[$field_6]",
                  "class": "ms-fontColor-neutralPrimary sp-card-content  sp-card-multiline"
                },
                "txtContent": "=if ([$field_6] == '', '–', [$field_6])",
                "style": {
                  "height": "40px",
                  "font-weight": "bold",
                  "font-size": "14px"
                }
              }
            ]
          }
        ]
      }
    ]
  }
}
6
  • Try using [$Progression] instead of $Progression at all the places in JSON. You can get the internal name of your SharePoint list columns by following this article: How to find the Internal name of columns in SharePoint Online?. Let me know if it works for you or not. Jan 8 at 13:33
  • Also, you cannot check background-color value using [$background-color] in SharePoint JSON formatting. You will have to use the same expression again in color property. Jan 8 at 13:36
  • 1
    Hello Ganesh thxs so much, now the icons display :)
    – Hervé
    Jan 8 at 17:25
  • Great, glad it worked for you. Jan 8 at 18:00
  • Hello Ganesh thxs so much, now the icons display :) However colors dont match the expected. as you mention in your "background-color" comment. Sorry if i didnt understand it clearly. I have tried playing around but did not succeed to make it better. Here is how it appears : imgur.com/a/kRT4KTo
    – Hervé
    Jan 8 at 18:06

1 Answer 1

0

In SharePoint Online JSON formatting, you have to reference the columns with this format: [$InternalNameOfColumn].

So, try using [$Progression] instead of $Progression at all the places in JSON.

You can get the exact internal name of your SharePoint list columns by following this article: How to find the Internal name of columns in SharePoint Online?


Also, you cannot check background-color value using [$background-color] in SharePoint JSON formatting. You will have to use the same expression again in color property (similar to the expressions you used for background-color property).

For example:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
  "hideSelection": true,
  "hideColumnHeader": true,
  "rowFormatter": {
    "elmType": "div",
    "_comment_": "MAIN DIV",
    "attributes": {
      "class": "ms-bgColor-neutralLighter"
    },
    "style": {
      "display": "flex",
      "flex-wrap": "wrap",
      "align-items": "stretch",
      "justify-content": "flex-start",
      "flex-direction": "row",
      "padding": "20px",
      "margin-bottom": "16px",
      "max-width": "1200px",
      "border-radius": "8px"
    },
    "children": [
      {
        "elmType": "div",
        "__comment": "GAUCHE",
        "style": {
          "flex-grow": "1",
          "display": "inline-block",
          "flex-direction": "column",
          "flex-wrap": "nowrap",
          "align-items": "left",
          "max-width": "200px",
          "min-width": "100px",
          "margin-right": "95px",
          "text-align": "left"
        },
        "children": [
          {
            "elmType": "span",
            "txtContent": "=[$field_0]",
            "style": {
              "font-weight": "bold",
              "font-size": "16px",
              "color": "#FFFFFF",
              "background-color": {
                "operator": ":",
                "operands": [
                  {
                    "operator": "==",
                    "operands": [
                      "[$field_0]",
                      "One TSC"
                    ]
                  },
                  "#FF7700",
                  {
                    "operator": ":",
                    "operands": [
                      {
                        "operator": "==",
                        "operands": [
                          "[$field_0]",
                          "Make or Buy"
                        ]
                      },
                      "#50BE87",
                      {
                        "operator": ":",
                        "operands": [
                          {
                            "operator": "==",
                            "operands": [
                              "[$field_0]",
                              "Performance"
                            ]
                          },
                          "#4BB4E6",
                          {
                            "operator": ":",
                            "operands": [
                              {
                                "operator": "==",
                                "operands": [
                                  "[$field_0]",
                                  "Formation - Consignes"
                                ]
                              },
                              " #FFB4E6",
                              {
                                "operator": ":",
                                "operands": [
                                  {
                                    "operator": "==",
                                    "operands": [
                                      "[$field_0]",
                                      "Poste de travail"
                                    ]
                                  },
                                  "#FFD200",
                                  "#800080"
                                ]
                              }
                            ]
                          }
                        ]
                      }
                    ]
                  }
                ]
              },
              "border-radius": "20px",
              "padding": "5px 10px"
            }
          },
          {
            "elmType": "div",
            "txtContent": "=[$Title]",
            "style": {
              "font-weight": "bold",
              "font-size": "16px",
              "color": {
                "operator": ":",
                "operands": [
                  {
                    "operator": "==",
                    "operands": [
                      "[$field_0]",
                      "One TSC"
                    ]
                  },
                  "#FF7700",
                  "#000000"
                ]
              },
              "white-space": "normal",
              "padding-top": "20px",
              "padding-left": "1px"
            }
          }
        ]
      },
      {
        "elmType": "div",
        "__comment": "MILIEU",
        "style": {
          "flex-grow": "1",
          "display": "flex",
          "flex-direction": "column",
          "flex-wrap": "nowrap",
          "align-items": "left",
          "max-width": "400px",
          "min-width": "205px"
        },
        "children": [
          {
            "elmType": "div",
            "_comment": " DIV_ACTION",
            "style": {
              "display": "block"
            },
            "children": [
              {
                "elmType": "span",
                "attributes": {
                  "iconName": "BullseyeTarget"
                },
                "style": {
                  "font-size": "14px",
                  "padding-right": "5px",
                  "color": "grey"
                }
              },
              {
                "elmType": "span",
                "txtContent": "Action",
                "style": {
                  "font-size": "14px",
                  "color": "grey"
                }
              },
              {
                "elmType": "span",
                "txtContent": "=[$field_2]",
                "style": {
                  "font-size": "14px",
                  "font-weight": "bold",
                  "white-space": "normal",
                  "word-break": "break-word",
                  "display": "-webkit-box",
                  "text-overflow": "ellipsis",
                  "overflow": "hidden",
                  "word-wrap": "break-word"
                }
              }
            ]
          },
          {
            "elmType": "div",
            "_comment": "DIV_DELAI",
            "attributes": {
              "class": "sp-card-displayColumnContainer"
            },
            "children": [
              {
                "elmType": "div",
                "attributes": {
                  "iconName": "Calendar"
                },
                "style": {
                  "font-size": "14px",
                  "padding-right": "5px",
                  "color": "grey",
                  "padding-top": "20px"
                }
              },
              {
                "elmType": "span",
                "txtContent": "Délai",
                "style": {
                  "color": "grey",
                  "font-size": "14px"
                }
              },
              {
                "elmType": "p",
                "attributes": {
                  "title": "[$field_3]",
                  "class": "ms-fontColor-neutralPrimary sp-card-content  sp-card-multiline"
                },
                "txtContent": "=if ([$field_3] == '', '–', [$field_3])",
                "style": {
                  "font-weight": "bold",
                  "font-size": "14px"
                }
              },
              {
                "elmType": "div",
                "_comment": "DIV_PROGRESSION",
                "style": {
                  "display": "block"
                },
                "children": [
                  {
                    "elmType": "span",
                    "attributes": {
                      "iconName": "Financial"
                    },
                    "style": {
                      "font-size": "14px",
                      "padding-right": "5px",
                      "color": "grey"
                    }
                  },
                  {
                    "elmType": "span",
                    "txtContent": "Avancement",
                    "style": {
                      "font-size": "14px",
                      "color": "grey"
                    }
                  },
                  {
                    "elmType": "div",
                    "style": {
                      "font-size": "16px"
                    },
                    "children": [
                      {
                        "elmType": "span",
                        "attributes": {
                          "title": "0-20%",
                          "iconName": "=if([$Progression] < 1, 'CircleRing', 'SkypeCircleCheck')",
                          "class": "='ms-fontColor-' + if([$Progression] == 1, 'green', if([$Progression] > 1, 'greenLight', 'neutralLight'))"
                        },
                        "style": {
                          "padding": "0 2px"
                        }
                      },
                      {
                        "elmType": "span",
                        "attributes": {
                          "title": "Step 2",
                          "iconName": "=if([$Progression] < 2, 'CircleRing', 'SkypeCircleCheck')"
                        },
                        "style": {
                          "padding": "0 2px"
                        }
                      },
                      {
                        "elmType": "span",
                        "attributes": {
                          "title": "Step 3",
                          "iconName": "=if([$Progression] < 3, 'CircleRing', 'SkypeCircleCheck')",
                          "class": "='ms-fontColor-' + if([$Progression] == 3, 'green', if([$Progression] > 3, 'greenLight', 'neutralLight'))"
                        },
                        "style": {
                          "padding": "0 2px"
                        }
                      },
                      {
                        "elmType": "span",
                        "attributes": {
                          "title": "Step 4",
                          "iconName": "=if([$Progression] < 4, 'CircleRing', 'SkypeCircleCheck')",
                          "class": "='ms-fontColor-' + if([$Progression] == 4, 'green', if([$Progression] > 4, 'greenLight', 'neutralLight'))"
                        },
                        "style": {
                          "padding": "0 2px"
                        }
                      },
                      {
                        "elmType": "span",
                        "attributes": {
                          "title": "Step 5",
                          "iconName": "=if([$Progression] < 5, 'CircleRing', 'SkypeCircleCheck')",
                          "class": "='ms-fontColor-' + if([$Progression] == 5, 'green', if([$Progression] > 5, 'greenLight', 'neutralLight'))"
                        },
                        "style": {
                          "padding": "0 2px"
                        }
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "elmType": "div",
        "__comment": "DROITE",
        "style": {
          "flex-grow": "1",
          "display": "flex",
          "flex-direction": "column",
          "flex-wrap": "nowrap",
          "align-items": "left",
          "max-width": "300px",
          "min-width": "205px"
        },
        "children": [
          {
            "elmType": "div",
            "_comment": " DIV_PORTEUR",
            "style": {
              "display": "block"
            },
            "children": [
              {
                "elmType": "span",
                "attributes": {
                  "iconName": "Telemarketer"
                },
                "style": {
                  "font-size": "14px",
                  "padding-right": "5px",
                  "color": "grey"
                }
              },
              {
                "elmType": "span",
                "txtContent": "Porteur",
                "style": {
                  "font-size": "14px",
                  "color": "grey"
                }
              },
              {
                "elmType": "span",
                "txtContent": "=[$field_2]",
                "style": {
                  "font-size": "14px",
                  "font-weight": "bold",
                  "white-space": "normal",
                  "word-break": "break-word",
                  "display": "-webkit-box",
                  "text-overflow": "ellipsis",
                  "overflow": "hidden",
                  "word-wrap": "break-word"
                }
              }
            ]
          },
          {
            "elmType": "div",
            "_comment": "DIV_CONTRIBUTEUR",
            "attributes": {
              "class": "sp-card-displayColumnContainer"
            },
            "children": [
              {
                "elmType": "div",
                "attributes": {
                  "iconName": "Touch"
                },
                "style": {
                  "font-size": "14px",
                  "padding-right": "5px",
                  "color": "grey",
                  "padding-top": "20px"
                }
              },
              {
                "elmType": "span",
                "txtContent": "Contributeur(s)",
                "style": {
                  "color": "grey",
                  "font-size": "14px",
                  "padding-top": "20px"
                }
              },
              {
                "elmType": "p",
                "attributes": {
                  "title": "[$field_6]",
                  "class": "ms-fontColor-neutralPrimary sp-card-content  sp-card-multiline"
                },
                "txtContent": "=if ([$field_6] == '', '–', [$field_6])",
                "style": {
                  "height": "40px",
                  "font-weight": "bold",
                  "font-size": "14px"
                }
              }
            ]
          }
        ]
      }
    ]
  }
}
1
  • 1
    Ok i got it and it displays well. Thxs so much for your time.
    – Hervé
    Jan 8 at 23:20

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.