Share via

Sharepoint List view formatting issue

Anonymous
2024-04-28T05:06:32+00:00

Sharepoint Online. My list has 4 fields "Company", "PrimaryContact", "PrimaryContactEmail", and "PrimaryContactPhone". I want to create a view which will display Primary Contact info as one column. This is json formatting that I applied to PrimaryContact column.

{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "style": { "display": "flex", "flex-wrap": "wrap", "align-items": "stretch" }, "children": [ { "elmType": "div", "txtContent": "[$PrimaryContact]", "style": { "font-weight": "bold", "padding-top": "5px" } }, { "elmType": "a", "style": { "display": "=if([$PrimaryContactEmail] == '', 'none', 'block')", "width": "100%" }, "attributes": { "class": "ms-fontSize-xs ms-fontWeight-regular ms-fontColor-neutralPrimary ms-fontColor-themePrimary--hover", "href": "='mailto:' + [$PrimaryContactEmail]" }, "children": [ { "elmType": "span", "attributes": { "iconName": "Mail", "class": "ms-fontColor-themePrimary" }, "style": { "padding-right": "6px" } }, { "elmType": "span", "txtContent": "[$PrimaryContactEmail]" } ] }, { "elmType": "div", "style": { "display": "=if([$PrimaryContactPhone] == '', 'none', 'block')", "width": "100%" }, "attributes": { "class": "ms-fontSize-xs ms-fontWeight-regular ms-fontColor-neutralPrimary ms-fontColor-themePrimary--hover" }, "children": [ { "elmType": "span", "attributes": { "iconName": "Phone", "class": "ms-fontColor-themePrimary" }, "style": { "padding-right": "6px", "padding-bottom": "7px" } }, { "elmType": "span", "txtContent": "[$PrimaryContactPhone]" } ] } ] }

It does what I want. I created a view where I hide "PrimaryContactEmail" and "PrimaryContactPhone" since I don't need them as a separate columns anymore.

If I navigate to site content my list and select my view, I see two columns "Company" and "PrimaryContact" as expected. Column "PrimaryContact" displays data from "PrimaryContact", "PrimaryContactEmail", "PrimaryContactPhone" fields. Next, I want to show this list on a page. When I add web part list to a page, select my list and select my view, it shows my list correctly. However, info from columns "PrimaryContactEmail", "PrimaryContactPhone" disappears from column "PrimaryContact" as soon as I save the page or publish it. Is it a bug or a feature? How to display info from 3 fields in one column properly?

Microsoft 365 and Office | SharePoint | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Anonymous
    2024-04-29T00:12:54+00:00

    Dear respected,

    Thanks for your waiting.

    I understand your concern but since you concern is related to JSON code on formatting SharePoint list view, I suggest you post your concern in the Questions - Microsoft Q&A with SharePoint Developmenttag or the GitHub sp-dev-docs to get the detailed help from the experts. For reference: Support and Feedback | Microsoft Learn

    Image Image

    Apologies for redirecting you to a different community as the members in the category posted focus on the users with out-of-the-box features in SharePoint Online platform and have limited knowledge on the JSON coding or SharePoint customization, so to get the fast and better assistance for your code of formatting views, we have redirected you to the correct community.

    In addition, I will keep this thread open so that SharePoint MVPs in this community may share their ideas or other possible workarounds on your requirement.

    Appreciate your patience and understanding. Have a great day!!

    Best Regards,

    Mia

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2024-04-28T10:55:23+00:00

    Dear SP_147

    Good day!

    Thank you for posting to Microsoft Community. We are glad to assist. We are looking into your situation and we will update the thread shortly.

    Appreciate your patience and understanding and thank for your time and cooperation.

    Sincerely,

    Tin

    Was this answer helpful?

    0 comments No comments