SOLVED

Sharepoint lists - Conditional formating, multiple lines column.

%3CLINGO-SUB%20id%3D%22lingo-sub-2263566%22%20slang%3D%22en-US%22%3ESharepoint%20lists%20-%20Conditional%20formating%2C%20multiple%20lines%20column.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2263566%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20it%20possible%20to%20format%20a%20columns%20in%20lists%2C%20based%20on%20a%20%22multiple%20lines%22%20eg%20if%20it%20it%20contains%20text%2C%20not%20empty.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22lists%20cond%20formating.PNG%22%20style%3D%22width%3A%20389px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F271452i439EE475ED556069%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22lists%20cond%20formating.PNG%22%20alt%3D%22lists%20cond%20formating.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20columns%20name%20is%20%22Kommentarer%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBest%20regards%3C%2FP%3E%3CP%3E-%20Geir%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2263566%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ELists%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2263615%22%20slang%3D%22en-US%22%3ERe%3A%20Sharepoint%20lists%20-%20Conditional%20formating%2C%20multiple%20lines%20column.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2263615%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F9195%22%20target%3D%22_blank%22%3E%40Geir%20Hogstad%3C%2FA%3E%26nbsp%3Byes%20this%20is%20possible%20and%20you%20can%20see%20this%20in%20the%20More...%20multiple%20lines%20of%20text%20column%20in%20the%20image%20below.%20If%20there%20is%20text%20then%20the%20background%20color%20is%20blue%2C%20but%20the%20background%20stays%20white%20if%20there%20is%20no%20text%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22multiLineJSON.png%22%20style%3D%22width%3A%20905px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F271456iD47D68C7F824E212%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22multiLineJSON.png%22%20alt%3D%22multiLineJSON.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPut%20the%20following%20JSON%20in%20the%20advanced%20mode%20screen%20when%20you%20format%20the%20column%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%7B%0A%20%20%22%24schema%22%3A%20%22https%3A%2F%2Fdeveloper.microsoft.com%2Fjson-schemas%2Fsp%2Fcolumn-formatting.schema.json%22%2C%0A%20%20%22elmType%22%3A%20%22div%22%2C%0A%20%20%22txtContent%22%3A%20%22%40currentField%22%2C%0A%20%20%22style%22%3A%20%7B%0A%20%20%20%20%22padding-left%22%3A%20%2214px%22%2C%0A%20%20%20%20%22background-color%22%3A%20%22%3Dif(%40currentField%20!%3D%20''%2C'%234f7b95'%2C'%23fffffc')%22%2C%0A%20%20%20%20%22color%22%3A%20%22white%22%0A%20%20%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%3CBR%20%2F%3ERob%3CBR%20%2F%3ELos%20Gallardos%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23006400%22%3EMicrosoft%20Power%20Automate%20Community%20Super%20User%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Regular Contributor

Hi,

 

Is it possible to format a columns in lists, based on a "multiple lines" eg if it it contains text, not empty.

lists cond formating.PNG

 

The columns name is "Kommentarer"

 

Best regards

- Geir

 

 

 

3 Replies
best response confirmed by Geir Hogstad (Regular Contributor)
Solution

@Geir Hogstad yes this is possible and you can see this in the More... multiple lines of text column in the image below. If there is text then the background color is blue, but the background stays white if there is no text:

multiLineJSON.png

 

Put the following JSON in the advanced mode screen when you format the column:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
    "padding-left": "14px",
    "background-color": "=if(@currentField != '','#4f7b95','#fffffc')",
    "color": "white"
  }
}


Rob
Los Gallardos
Microsoft Power Automate Community Super User

Great, thank you.

Best Regards
- Geir

@RobElliottWhat about if you have "Append changes to existing text" turned on? My use case has the append option selected. I'd like to highlight my column if changes have been made, and no background if there are no changes (something like below). This would be a visual cue for users to quickly see if changes (or really comments as I'm using it as a call log) have been made. Thanks...

 

CallLogexample.png