0

Question:

How can I enforce to load a column with data without it being seen as a separate column?

Problem:

I have two columns, title and summary. Now I would like to display only title in list view and show the summary as a 'popup'. I do not wish to show summary as a separate stand alone column in list view.

Created the list formatting as shown below. The problem occurs in when I do not have summary as a separate standalone column the value [$Summary] will be empty, as if the column with values has not been loaded.

Is it possible to fix this?

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "attributes": {
    "href": "some link"
  },
  "txtContent": "[$Title]",
  "customCardProps": {
    "formatter": {
      "elmType": "div",
      "txtContent": "[$Summary]",
      "style": {
        "width": "500px",
        "padding": "20px"
      }
    },
    "openOnEvent": "hover",
    "directionalHint": "bottomCenter",
    "isBeakVisible": true,
    "beakStyle": {
      "backgroundColor": "white"
    }
  }
}
2
  • what is the type of Summary field? is it multiline of text or single text? Commented Aug 27, 2022 at 5:09
  • Single line text
    – WG-
    Commented Aug 27, 2022 at 18:16

4 Answers 4

2

On top of Ganesh's input,

There is work around where you can still use column value in Column Formatting even if you don't add it as View Columns.

You can use Summary column either in View Filter Criteria or Order by. As you mentioned that Summary column does have Single Line of text field then you can use this work around.

Update you view and add "Summary" column as second Sort field and remove it from view field as mentioned in below screen shot:

enter image description here

Now your Column Formatting would work as expected as shown in below screen shot:

enter image description here

2
  • That is really clever! I will be using this!
    – WG-
    Commented Aug 30, 2022 at 7:23
  • Thanks Kalpesh, Yes that is clever solution :)
    – Saira
    Commented Sep 14, 2022 at 22:32
1

Unfortunately, No. This is a known issue while using JSON formatting in SharePoint. In order to reference the Summary column in JSON, it should be included in the list view.

Official documentations:

  1. Use column formatting to customize SharePoint
  2. Use view formatting to customize SharePoint
4
  • That is a bummer...
    – WG-
    Commented Aug 26, 2022 at 14:10
  • any idea if you can vote somewhere to resolve this issue?
    – WG-
    Commented Aug 26, 2022 at 14:11
  • 1
    Microsoft discontinued previous idea/suggestion platform (UserVoice) & Created their own feedback portal. You can find it at: feedbackportal.microsoft.com/feedback/forum/… There might be some ideas related to same topic where you can vote OR you can create a new idea/suggestion by yourself. Commented Aug 26, 2022 at 14:29
  • I will try to find the direct links to feedback & update here. Meanwhile you can check the feedback portal by yourself. Thank you. Commented Aug 26, 2022 at 14:30
0

My suggestion would be to create a calculated field that references the hidden field, and then utilize the calculated field in the view. This approach allows for access to the field and enables formatting in the style tag if the condition is met.

(Source: https://www.youtube.com/watch?v=FH_lTDzAnes)

0

As additional information to the excellent tip Kalpesh provided, here is the description of the weird behavior when applied to Yes/No columns (at least with SharePoint on Microsoft 365).

When the Yes/No column is part of the visible column in the view you can use the column value as a Boolean in formatting e.g., if([$MyYesNoColumn],'value if Yes','value if No').

However, and surprisingly, when the column is not visible in the view (but referenced in sorting or filtering options as explained by Kalpesh). The value is NOT Boolean but text ('Yes' or 'No' if using English locale). You could rewrite above example as if([$MyYesNoColumn]=='No','value if No',if([$MyYesNoColumn],'value if Yes','value if No')) but it is not elegant nor does it cope with the different language/locale (e.g., if user is accessing SharePoint with French locale, the values of the column wouldbe "Oui" and "Non" instead of "Yes" and "No").

I could not find any workaround for that so far.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.