SOLVED

Conditional Formatting

%3CLINGO-SUB%20id%3D%22lingo-sub-1562997%22%20slang%3D%22en-US%22%3EConditional%20Formatting%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1562997%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20All%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20trying%20to%20use%20'Conditional%20formatting%20based%20on%20the%20value%20in%20a%20text%20or%20choice%20field%20(advanced)'%20in%20a%20SharePoint%20Online%20project%20tracking%20list%20and%20the%20formatting%20is%20not%20appearing%20on%20the%20list.%26nbsp%3B%20I%20used%20the%20JSON%20from%20the%20Microsoft%20Docs%20article%2C%20'Use%20column%20formatting%20to%20customize%20SharePoint%2C'%20and%20changed%20the%20names%20of%20the%20choice%20field%20names.%26nbsp%3B%20I'm%20not%20sure%20what%20I'm%20doing%20wrong.%26nbsp%3B%20I've%20used%20the%20view-formatting-schema%20as%20well%20and%20no%20change.%3C%2FP%3E%3CP%3E%3CFONT%20size%3D%222%22%20color%3D%22%23FF0000%22%3E%7B%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23FF0000%22%3E%22%24schema%22%3A%20%22%3CA%20href%3D%22https%3A%2F%2Fdeveloper.microsoft.com%2Fjson-schemas%2Fsp%2Fv2%2Fcolumn-formatting.schema.json%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdeveloper.microsoft.com%2Fjson-schemas%2Fsp%2Fv2%2Fcolumn-formatting.schema.json%3C%2FA%3E%22%2C%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23FF0000%22%3E%22elmType%22%3A%20%22div%22%2C%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23FF0000%22%3E%22attributes%22%3A%20%7B%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23FF0000%22%3E%22class%22%3A%20%22%3Dif(%40currentField%20%3D%3D%20'Closed'%2C%20'sp-field-severity--good'%2C%20if(%40currentField%20%3D%3D%20'Submitted'%2C%20'sp-field-severity--low'%2C%20if(%40currentField%20%3D%3D%20'Open'%2C%20'sp-field-severity--warning'%2C%20if(%40currentField%20%3D%3D%20'Potential%20RFI'%2C%20'sp-field-severity--severeWarning'%2C%20'sp-field-severity--blocked'))))%20%2B%20'%20ms-fontColor-neutralSecondary'%22%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23FF0000%22%3E%7D%2C%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23FF0000%22%3E%22children%22%3A%20%5B%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23FF0000%22%3E%7B%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23FF0000%22%3E%22elmType%22%3A%20%22span%22%2C%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23FF0000%22%3E%22style%22%3A%20%7B%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23FF0000%22%3E%22display%22%3A%20%22inline-block%22%2C%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23FF0000%22%3E%22padding%22%3A%20%220%204px%22%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23FF0000%22%3E%7D%2C%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23FF0000%22%3E%22attributes%22%3A%20%7B%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23FF0000%22%3E%22iconName%22%3A%20%22%3Dif(%40currentField%20%3D%3D%20'Closed'%2C%20'CheckMark'%2C%20if(%40currentField%20%3D%3D%20'Submitted'%2C%20'Forward'%2C%20if(%40currentField%20%3D%3D%20'Open'%2C%20'Error'%2C%20if(%40currentField%20%3D%3D%20'Potential%20RFI'%2C%20'Warning'%2C%20'ErrorBadge'))))%22%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23FF0000%22%3E%7D%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23FF0000%22%3E%7D%2C%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23FF0000%22%3E%7B%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23FF0000%22%3E%22elmType%22%3A%20%22span%22%2C%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23FF0000%22%3E%22txtContent%22%3A%20%22%40currentField%22%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23FF0000%22%3E%7D%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23FF0000%22%3E%5D%3C%2FFONT%3E%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23FF0000%22%3E%7D%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20any%20assistance!%3C%2FP%3E%3CP%3EPatti%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1562997%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1574305%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20Formatting%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1574305%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F565483%22%20target%3D%22_blank%22%3E%40PLove59%3C%2FA%3E%2C%20I%20just%20used%20the%20same%20json%20below%20and%20applied%20to%20the%20text%20and%20the%20choice%20field%20type%2C%20it%20works%20without%20any%20change.%20See%20the%20screenshot%20below%20and%20the%20json%20used.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F211070i57FACBDE26EAC4F2%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%7B%0A%20%20%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%20%20%22elmType%22%3A%20%22div%22%2C%0A%20%20%20%20%22attributes%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22class%22%3A%20%22%3Dif(%40currentField%20%3D%3D%20'Closed'%2C%20'sp-field-severity--good'%2C%20if(%40currentField%20%3D%3D%20'Submitted'%2C%20'sp-field-severity--low'%2C%20if(%40currentField%20%3D%3D%20'Open'%2C%20'sp-field-severity--warning'%2C%20if(%40currentField%20%3D%3D%20'Potential%20RFI'%2C%20'sp-field-severity--severeWarning'%2C%20'sp-field-severity--blocked'))))%20%2B%20'%20ms-fontColor-neutralSecondary'%22%0A%20%20%20%20%7D%2C%0A%20%20%20%20%22children%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22elmType%22%3A%20%22span%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22style%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%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%20%20%20%20%20%20%20%20%22padding%22%3A%20%220%204px%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22attributes%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22iconName%22%3A%20%22%3Dif(%40currentField%20%3D%3D%20'Closed'%2C%20'CheckMark'%2C%20if(%40currentField%20%3D%3D%20'Submitted'%2C%20'Forward'%2C%20if(%40currentField%20%3D%3D%20'Open'%2C%20'Error'%2C%20if(%40currentField%20%3D%3D%20'Potential%20RFI'%2C%20'Warning'%2C%20'ErrorBadge'))))%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22elmType%22%3A%20%22span%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22txtContent%22%3A%20%22%40currentField%22%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%5D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1577286%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20Formatting%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1577286%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F565483%22%20target%3D%22_blank%22%3E%40PLove59%3C%2FA%3E%26nbsp%3B%2C%20Is%20there%20any%20invalid%20JSON%20error%20or%20any%20other%20error%20in%20browser's%20console%20while%20applying%20this%20JSON%20code.%20Also%2C%20make%20sure%20you%20are%20applying%20this%20JSON%20to%20correct%20column%20where%20the%20said%20choices%20in%20code%20are%20available%20correctly%20(even%20case-sensitivity%20of%20choices).%3C%2FP%3E%3CP%3EAlso%2C%20if%20you%20are%20referencing%20any%20other%20columns%20(nothing%20that%20I%20see%20in%20above%20mentioned%20JSON)%20then%20make%20sure%20you%20are%20using%20their%20%3CSTRONG%3Einternal%3C%2FSTRONG%3E%20names%20in%20your%20code%20correctly.%3C%2FP%3E%3CHR%20%2F%3E%3CP%3EPlease%20click%20%3CSTRONG%3EMark%20as%20Best%20Response%3C%2FSTRONG%3E%20if%20my%20post%20helped%20you%20solve%20your%20issue.%20This%20will%20help%20others%20find%20the%20correct%20solution%20easily.%20It%20also%20closes%20the%20item.%20If%20the%20content%20was%20useful%20in%20other%20ways%2C%20please%20consider%20giving%20it%20%3CSTRONG%3E%3CSTRONG%3ELike%3C%2FSTRONG%3E%3C%2FSTRONG%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1581755%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20Formatting%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1581755%22%20slang%3D%22en-US%22%3EThank%20you%20for%20the%20response.%20Adding%20the%20JSON%20to%20the%20'Status'%20column%20and%20not%20the%20'View%20formatting'%20worked!%20Thank%20you%20again%20...%20Patti%3C%2FLINGO-BODY%3E
Contributor

Hello All,

 

I'm trying to use 'Conditional formatting based on the value in a text or choice field (advanced)' in a SharePoint Online project tracking list and the formatting is not appearing on the list.  I used the JSON from the Microsoft Docs article, 'Use column formatting to customize SharePoint,' and changed the names of the choice field names.  I'm not sure what I'm doing wrong.  I've used the view-formatting-schema as well and no change.

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"attributes": {
"class": "=if(@currentField == 'Closed', 'sp-field-severity--good', if(@currentField == 'Submitted', 'sp-field-severity--low', if(@currentField == 'Open', 'sp-field-severity--warning', if(@currentField == 'Potential RFI', '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 == 'Closed', 'CheckMark', if(@currentField == 'Submitted', 'Forward', if(@currentField == 'Open', 'Error', if(@currentField == 'Potential RFI', 'Warning', 'ErrorBadge'))))"
}
},
{
"elmType": "span",
"txtContent": "@currentField"
}
]
}

 

Thanks for any assistance!

Patti

 

 

3 Replies

Hi @PLove59, I just used the same json below and applied to the text and the choice field type, it works without any change. See the screenshot below and the json used.

 

image.png

 

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "attributes": {
        "class": "=if(@currentField == 'Closed', 'sp-field-severity--good', if(@currentField == 'Submitted', 'sp-field-severity--low', if(@currentField == 'Open', 'sp-field-severity--warning', if(@currentField == 'Potential RFI', '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 == 'Closed', 'CheckMark', if(@currentField == 'Submitted', 'Forward', if(@currentField == 'Open', 'Error', if(@currentField == 'Potential RFI', 'Warning', 'ErrorBadge'))))"
            }
        },
        {
            "elmType": "span",
            "txtContent": "@currentField"
        }
    ]
}
best response confirmed by PLove59 (Contributor)
Solution

@PLove59 , Is there any invalid JSON error or any other error in browser's console while applying this JSON code. Also, make sure you are applying this JSON to correct column where the said choices in code are available correctly (even case-sensitivity of choices).

Also, if you are referencing any other columns (nothing that I see in above mentioned JSON) then make sure you are using their internal names in your code correctly.


Please click Mark as Best Response if my post helped you solve your issue. This will help others find the correct solution easily. It also closes the item. If the content was useful in other ways, please consider giving it Like.

 

Thank you for the response. Adding the JSON to the 'Status' column and not the 'View formatting' worked! Thank you again ... Patti