Forum Discussion

Alessandro_Ansa's avatar
Alessandro_Ansa
Copper Contributor
Jun 26, 2020
Solved

JSON column formatting with Flow

Hi all

 

I'm trying to automate the build of a SharePoint list that is formatted with JSON so that I can easily reuse it on new projects. I've built a Flow that uses http requests to create the list, is it possible to also send the JSON formatting info through an http request from Flow? If so, how could I do this?

 

Thanks in advance 

3 Replies

    • NeilMcc1400's avatar
      NeilMcc1400
      Copper Contributor

      Hey Alessandro_Ansa ,

       

      I've been trying to achieve the same thing. Could you show an example of CustomFormatter, so I can see the JSON formatting? Thanks!

      • alessandroansa's avatar
        alessandroansa
        Copper Contributor

        NeilMcc1400 

         

        Hi Neil

         

        I first initialized a variable (which I called CustomFormatStatus) to hold all the JSON, so something like this (note the use of backslash to comment out the quote marks):

        {
          "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
          "elmType": "div",
          "attributes": {
            "class": "=if(@currentField == \'Complete\', \'sp-field-severity--good\', if(@currentField == \'In Progress\', \'sp-field-severity--low\', if(@currentField == \'In Review\', \'sp-field-severity--warning\', if(@currentField == \'Not started\', \'sp-field-severity--severeWarning\', \'sp-field-severity--blocked\')))) + \' ms-fontColor-neutralSecondary\'"
          },
          "children": [
            {
              "elmType": "span",
              "style": {
                "display": "inline-block",
                "padding": "0 4px"
              },
              "attributes": {
                "iconName": "=if(@currentField == \'Complete\', \'Accept\', if(@currentField == \'In Progress\', \'Forward\', if(@currentField == \'In Review\', \'Edit\', if(@currentField == \'Not started\', \'Warning\', \'ErrorBadge\'))))"
              }
            },
            {
              "elmType": "span",
              "txtContent": "@currentField"
            }
          ]
        }

         

        Then in the HTTP request I use the customformatter property to call the variable:

        { '__metadata': { 'type': 'SP.FieldChoice' },
        'Title': 'Status',
        'Choices': { 'results': ['Not started', 'In Progress', 'In Review', 'Complete'] },
        'CustomFormatter': '@{variables('CustomFormatStatus')}'
        }

         

Resources