SharePoint Row Formatting in Picture Library (bug??)

Carl Williams 236 Reputation points
2020-11-25T01:12:15.43+00:00

Good day.

  • I'm trying to do some conditional formatting on a photo library in list mode.
  • Very simply, if the item has not been applied a related asset (Asset lookup field) then the row should simply be red.
  • Below are images of my list and the JSON I used.
  • You can see ALL records are red(?????) Just the bottom/last one should be red . I obtained the example from Microsoft.
  • Seems as if there is a bug with doing this in Picture libraries but Microsoft tech support seems to think it's out of scope. The designer mode doesn't work, all it does is allow one to choose the 'Modified" field in picture libraries(?????)

42297-2json1.png

You can see in the image, the one row with an empty 'Asset' which should be pink and all others white. But they're all pink
42240-json1.png

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,679 questions
0 comments No comments
{count} votes

Accepted answer
  1. Itch Sun-MSFT 2,556 Reputation points
    2020-11-25T07:51:55.39+00:00

    Hi @Carl Williams

    Since you are using a lookup column, we need to perform some conversion on the column.

    You can refer to the following code, it can run normally in my test:

    {  
      "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",  
      "debugMode": true,  
      "elmType": "div",  
      "attributes": {  
        "class": "=if(@currentField.lookupValue == '','sp-field-severity--severeWarning','')"  
      },  
      "children": [  
        {  
          "elmType": "span",  
          "style": {  
            "display": "inline-block",  
            "padding": "0 4px"  
          }  
        },  
        {  
          "elmType": "span",  
          "txtContent": "@currentField.lookupValue"  
        }  
      ]  
    }  
    

    42507-image.png


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


2 additional answers

Sort by: Most helpful
  1. Carl Williams 236 Reputation points
    2020-11-25T01:17:59.293+00:00

    As I mentioned, the JSON was from Microsoft's formatting views document:

    view-formatting

    I simply changed the name of the field and and the if statement to [= ''] and still it didn't work. I find most things I try to accomplish in SPO, Power apps don't really work as expected.

    {  
      "$schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",  
       "additionalRowClass": "=if([$DueDate] <= @now, 'sp-field-severity--severeWarning', '')"  
    }  
    
    0 comments No comments

  2. Carl Williams 236 Reputation points
    2020-11-26T00:39:17.91+00:00

    BTW. Is this possible with the entire row??

    I changed @currentField.lookupValue to [$Asset] in both instances but that didn't change anything, then I tried [$Asset].lookupValue and that didnt do anything either. :(


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.