2

SharePoint and it pointless limitations (or bugs) drive me crazy again...

I have a list, that is used by different people. As it´s still not possible to color headers or similar, I got used to insert lines left or right of a column via conditional formatting. With such, I create "blocks" of columns for each user. Better than nothing... But now comes the kicker.

It worked fine so far, but now with a lookup column, the content just disappears.

This is my list without the border, numbers visible to the left.

List without formatting

Now with formatting applied to the left lookup column, the content is just gone.

List with formatting

I start with "no style" at formatting, as I only want to have the border. The teaser clearly shows, that text should be visible:

Conditional Formatting Sample

The json code has some "hidden" attributes in there, but no matter what I change, the content does not reappear.

 "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "style": { "box-sizing": "border-box", "padding": "0 2px", "overflow": "hidden", "text-overflow": "ellipsis" }, "attributes": { "class": "sp-field-borderRightBold sp-field-borderRightSolid sp-field-fontSizeMedium" }, "children": [ { "elmType": "span", "style": { "overflow": "hidden", "text-overflow": "ellipsis", "padding": "0 3px" }, "txtContent": "[$PA_x0020_Nr_x002e__x003a__x0020_.lookupValue]", "attributes": { "class": "sp-field-fontSizeMedium" } } ] } 

Please help... How do I get the border AND my content?

Thanks!

3
  • Should have asked AI directly... Solution is in the code. The reference in the lookup value is not woking. By replacing it with "@currentField", the formatting works fine. Commented Dec 11, 2024 at 9:51
  • Glad that you get the solution quickly. I would request you to add your correct JSON as an answer and accept it so it will be helpful to other members in future. Commented Dec 11, 2024 at 11:32
  • Good idea, Code posted below as answer Commented Dec 12, 2024 at 13:00

2 Answers 2

1
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "style": { "border-right": "3px solid black", "padding": "0 2px" }, "children": [ { "elmType": "div", "txtContent": "@currentField", "style": { "padding": "0 3px", "margin-top": "-4px" } } ] } 
1
  • Thank you for providing a solution to the problem and showing other community members useful information! Commented Dec 13, 2024 at 7:26
0

Similar issue here, but quite different: this bug shows also when some basic conditional formatting is applied to a lookup column, and content of "advanced mode" JSON shall be fixed to set "txtContent": "@currentField".


For instance, let’s say I have two lists:

  • a sub-list

    Title Status
    abc Some status
    def Other status
  • a list with lookup on the sub-list, showing its content

    Title Comment SubList:Title SubList:Status
    A BC A first row abc Some status

So far, so good. But then I want cells from the sub-list to be grayed-out, so that user understands at a glance that they are looked-up fields that cannot directly be edited. So I add conditional formatting on SubList:Status field, with condition that Title is not empty (which it cannot), and as a sudden the cell is colored as expected, but its content is hidden! :-o

Following the hereabove solution to this answer, I had a look in the conditional formatting "advanced mode" content, which is as follows:

{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "style": { "box-sizing": "border-box", "padding": "0 2px", "overflow": "hidden", "text-overflow": "ellipsis" }, "attributes": { "class": "sp-css-backgroundColor-BgLightGray sp-field-fontSizeSmall sp-css-color-LightGrayFont" }, "children": [ { "elmType": "span", "style": { "overflow": "hidden", "text-overflow": "ellipsis", "padding": "0 3px" }, "txtContent": "[$Id_x0020_SubList_Title.lookupValue]", "attributes": { "class": "sp-field-fontSizeSmall sp-css-color-LightGrayFont" } } ] } 

Notice the children[0].txtContent value?

Well, if I replace it with "@currentField", then tadaa, text is now correctly shown !

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.