SOLVED

JSON column formatting with Flow

%3CLINGO-SUB%20id%3D%22lingo-sub-1491794%22%20slang%3D%22en-US%22%3EJSON%20column%20formatting%20with%20Flow%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1491794%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20all%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20trying%20to%20automate%20the%20build%20of%20a%20SharePoint%20list%20that%20is%20formatted%20with%20JSON%20so%20that%20I%20can%20easily%20reuse%20it%20on%20new%20projects.%20I've%20built%20a%20Flow%20that%20uses%20http%20requests%20to%20create%20the%20list%2C%20is%20it%20possible%20to%20also%20send%20the%20JSON%20formatting%20info%20through%20an%20http%20request%20from%20Flow%3F%20If%20so%2C%20how%20could%20I%20do%20this%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20in%20advance%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1491794%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFlow%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EJSON%20formatting%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ELists%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1492630%22%20slang%3D%22en-US%22%3ERe%3A%20JSON%20column%20formatting%20with%20Flow%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1492630%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F635566%22%20target%3D%22_blank%22%3E%40Alessandro_Ansa%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWorked%20it%20out%20-%20it%20is%20achieved%20through%20the%20CustomFormatter%20property%20of%20SP.Fields%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1942764%22%20slang%3D%22en-US%22%3ERe%3A%20JSON%20column%20formatting%20with%20Flow%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1942764%22%20slang%3D%22en-US%22%3E%3CP%3EHey%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F635566%22%20target%3D%22_blank%22%3E%40Alessandro_Ansa%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20been%20trying%20to%20achieve%20the%20same%20thing.%20Could%20you%20show%20an%20example%20of%26nbsp%3B%3CSPAN%3ECustomFormatter%2C%3C%2FSPAN%3E%20so%20I%20can%20see%20the%20JSON%20formatting%3F%20Thanks!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1944637%22%20slang%3D%22en-US%22%3ERe%3A%20JSON%20column%20formatting%20with%20Flow%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1944637%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F886348%22%20target%3D%22_blank%22%3E%40NeilMcc1400%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%20Neil%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20first%20initialized%20a%20variable%20(which%20I%20called%20CustomFormatStatus)%20to%20hold%20all%20the%20JSON%2C%20so%20something%20like%20this%20(note%20the%20use%20of%20backslash%20to%20comment%20out%20the%20quote%20marks)%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%7B%0A%20%20%22%24schema%22%3A%20%22https%3A%2F%2Fdeveloper.microsoft.com%2Fjson-schemas%2Fsp%2Fv2%2Fcolumn-formatting.schema.json%22%2C%0A%20%20%22elmType%22%3A%20%22div%22%2C%0A%20%20%22attributes%22%3A%20%7B%0A%20%20%20%20%22class%22%3A%20%22%3Dif(%40currentField%20%3D%3D%20%5C'Complete%5C'%2C%20%5C'sp-field-severity--good%5C'%2C%20if(%40currentField%20%3D%3D%20%5C'In%20Progress%5C'%2C%20%5C'sp-field-severity--low%5C'%2C%20if(%40currentField%20%3D%3D%20%5C'In%20Review%5C'%2C%20%5C'sp-field-severity--warning%5C'%2C%20if(%40currentField%20%3D%3D%20%5C'Not%20started%5C'%2C%20%5C'sp-field-severity--severeWarning%5C'%2C%20%5C'sp-field-severity--blocked%5C'))))%20%2B%20%5C'%20ms-fontColor-neutralSecondary%5C'%22%0A%20%20%7D%2C%0A%20%20%22children%22%3A%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22elmType%22%3A%20%22span%22%2C%0A%20%20%20%20%20%20%22style%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22display%22%3A%20%22inline-block%22%2C%0A%20%20%20%20%20%20%20%20%22padding%22%3A%20%220%204px%22%0A%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%22attributes%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22iconName%22%3A%20%22%3Dif(%40currentField%20%3D%3D%20%5C'Complete%5C'%2C%20%5C'Accept%5C'%2C%20if(%40currentField%20%3D%3D%20%5C'In%20Progress%5C'%2C%20%5C'Forward%5C'%2C%20if(%40currentField%20%3D%3D%20%5C'In%20Review%5C'%2C%20%5C'Edit%5C'%2C%20if(%40currentField%20%3D%3D%20%5C'Not%20started%5C'%2C%20%5C'Warning%5C'%2C%20%5C'ErrorBadge%5C'))))%22%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22elmType%22%3A%20%22span%22%2C%0A%20%20%20%20%20%20%22txtContent%22%3A%20%22%40currentField%22%0A%20%20%20%20%7D%0A%20%20%5D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThen%20in%20the%20HTTP%20request%20I%20use%20the%20customformatter%20property%20to%20call%20the%20variable%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%7B%20'__metadata'%3A%20%7B%20'type'%3A%20'SP.FieldChoice'%20%7D%2C%0A'Title'%3A%20'Status'%2C%0A'Choices'%3A%20%7B%20'results'%3A%20%5B'Not%20started'%2C%20'In%20Progress'%2C%20'In%20Review'%2C%20'Complete'%5D%20%7D%2C%0A'CustomFormatter'%3A%20'%40%7Bvariables('CustomFormatStatus')%7D'%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

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
Best Response confirmed by Alessandro_Ansa (New Contributor)
Solution

@Alessandro_Ansa 

 

Worked it out - it is achieved through the CustomFormatter property of SP.Fields

 

Thanks

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!

@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')}'
}