Jun 26 2020 04:34 AM
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
Jun 26 2020 10:05 AM
Solution
Worked it out - it is achieved through the CustomFormatter property of SP.Fields
Thanks
Nov 30 2020 03:39 PM
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!
Dec 01 2020 06:43 AM
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')}'
}
Jun 26 2020 10:05 AM
Solution
Worked it out - it is achieved through the CustomFormatter property of SP.Fields
Thanks