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?