JSON formatting
30 TopicsSharePoint JSON Formatting using split and the resulting array
Hello, at https://learn.microsoft.com/de-de/sharepoint/dev/declarative-customization/formatting-syntax-reference I did find this for the split operator: split: divides the given string into an ordered list of substrings by searching for the given pattern, and returns an array of these substrings "txtContent": "=split('Hello World', ' ')" returns an array with 2 strings - 'Hello' and 'World' This returns: Hello, World Now with that given - I use this: { "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "txtContent": "=split([$Supervisor.email], '@')" } This returns: first.name,domain.com It does what it should. However my question is how can I address the array? So for example that only the index 0 of the array will be returned? Means only: first.name Or index 1 of the array, which would return only: domain.com At the end I need all elements of the array to build a new string I need. I want to create a delve link of the user profile to be opened at a new browser tab. I have all working except the string rebuild of the email. Side note: I have used the replace operator to solve my problem (not mentioned and shown here!) But, I want to learn more and like to know, how to use the split operator and access each operand of the array individually. Somebody knowing it and can explain? Many thanks for teaching me in advance. Cheers JKSolved12KViews0likes2CommentsSharePoint List. Gallery Formating
Good morning everyone. I'm trying to use a list to host a series of hyperlink. My list has 3 columns: 1) Title (The default one) 2) Topic (Hyperlink column) 3) Language (Radio button choice) I want to use this list as menu. Similar to the quick link Object in SharePoint (modern). I made all columns but "topic" invisible I created a Gallery view and ensure the column header doesn't appear in all items Now, I have no clue on how to format each tiles. If I make the font size bigger, the bottom of the text is cropped. If I make the size of the box bigger on list, I see the result but it's not reflected on what I see on Sharepoint So, my questions. 1) How to make my boxes larger (in both list and SharePoint) 2) How can I ensure the bottom of my text (The alternative text for the URL) is not cropped (usually the "p, q, g" ) 3) If my text it a bit too long, how can I allow it to take two lines one not only one) 4) How do I remove this little radio button in each tiles ? 5) How do I change the background color of the list object on SharePoint, the background and the background of the tiles ?1.4KViews0likes1CommentSharePoint library choice column formatting
I am trying to format a JSON for a Choice column that has been set to "choice pills". I am trying to change things like font color, background color, border etc. So far trying to do this but doesn't seem to work: { "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "style": { "flex-wrap": "wrap", "display": "flex" }, "children": [ { "forEach": "__INTERNAL__ in @currentField", "elmType": "div", "style": { "color": "=if(@currentField == 'Sales', '#ff0000', if(@currentField == 'Marketing', '#006aff', if(@currentField == 'Warehouse', '#b882d7','green')))", "background-color": "=if(@currentField == 'Sales', '#FAA0A0', if(@currentField == 'Marketing', '#c1d3f7', if(@currentField == 'Warehouse', '#e4c1f7','#DAF7A6')))", "box-sizing": "border-box", "padding": "4px 8px 5px 8px", "overflow": "hidden", "text-overflow": "ellipsis", "display": "flex", "border-radius": "16px", "height": "24px", "align-items": "center", "white-space": "nowrap", "margin": "4px 4px 4px 4px" }, "attributes": { "class": { "operator": ":", "operands": [ { "operator": "==", "operands": [ "[$__INTERNAL__]", "Sales" ] }, "sp-css-backgroundColor-BgCornflowerBlue sp-css-color-CornflowerBlueFont", { "operator": ":", "operands": [ { "operator": "==", "operands": [ "[$__INTERNAL__]", "Marketing" ] }, "sp-css-backgroundColor-BgMintGreen sp-css-color-MintGreenFont", { "operator": ":", "operands": [ { "operator": "==", "operands": [ "[$__INTERNAL__]", "Warehouse" ] }, "sp-css-backgroundColor-BgGold sp-css-color-GoldFont", "sp-field-borderAllRegular sp-field-borderAllSolid sp-css-borderColor-neutralSecondary" ] } ] } ] } }, "txtContent": "[$__INTERNAL__]" } ] }Solved3KViews0likes3CommentsClickable Button on Gallery View Document Library
Hello, I have a document library where social media assets are stored. I would like to create a gallery view of the document library that displays a "Download" button, so when the user selects, the file is automatically downloaded to their device. I have figured out how to add the Download button, which works perfectly in the List view. When you switch to gallery view, the button does not display, but I was able to get the button to show up by adding "columnFormatterReference": "[$Download]" to the Format view JSON. However, when the user clicks on the Download button from the gallery view, the file opens. I removed the following JSON code, so the file does not open in a new tab: "customRowAction": { "action": "defaultClick" Now I just need to figure out how to make the "Download" button clickable. Any help would be greatly appreciated. I'm brand-new to JSON and coding in general.Solved4.2KViews0likes9CommentsJSON column formatting - get user's phone number from people column
In a SharePoint list (M365), I have a people column. Even though the contact information is already included in the people column, users still want it displayed as separate columns. I used JSON formatting to grab the email address using [$ContactPerson.email] but I cannot figure out how to grab the phone number. I tried [$ContactPerson.businessphones], .telephonenumber, .phones but didn't work. As a work around, I just used Power Apps and default value: Substitute(Substitute(Substitute(First(Office365Users.UserProfileV2(DataCardValue2.Selected.Email).businessPhones).Value, "(", ""), ")", ""), " ", "-") Here's the code, I'd like to change the @currentField in line 22 to grab the phone# from [$ContactPerson]. { "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "children": [ { "elmType": "span", "style": { "display": "block", "color": "#333333", "text-align": "left", "font-size": "16px", "font-weight": "bold", "padding-top": "10px", "padding": "0 4px" }, "attributes": { "iconName": "Phone" } }, { "elmType": "a", "txtContent": "@currentField", "attributes": { "target": "_blank", "href": "='https://teams.microsoft.com/l/call/0/0?users=' + [$ContactPerson.email]" } } ] }Solved6KViews0likes1CommentConditional Formatting for List Header
First post here so forgive me if I am not detailed enough. I am creating an approval process and I am using this header formatting. As an example, for HR approval, I would like to tweak it for the HR approval portion to be hidden in the header until a certain text field is longer "null". I can hide it the list form itself but I am having trouble hiding the actual header. For my example, the below would only say "Manager Approval" until a text field (lets say "Name") is no longer "null". Along the lines of: =if([$Name]==true, 'true', 'false') Would this be possible?Solved2.2KViews0likes3CommentsTrying to Change the Gallery View with JSON to open custom URL instead of edit item menu
I have a simple list as follows: I'm trying to update the Gallery view so that when you click on the tile it opens the URL in "Form Link" instead of opening the standard "edit item" menu. I think I have to change the elmType to "a" instead of "button" but I've tried all combinations of href and target but I can't get it to work quite right. I'm fairly new to JSON does anyone have any suggestions? Here's my code: { "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/tile-formatting.schema.json", "height": 295, "width": 254, "hideSelection": false, "fillHorizontally": true, "formatter": { "elmType": "div", "attributes": { "class": "sp-card-container" }, "children": [ { "elmType": "button", "attributes": { "class": "sp-card-defaultClickButton" }, "customRowAction": { "action": "defaultClick" } }, { "elmType": "div", "attributes": { "class": "ms-bgColor-white sp-css-borderColor-neutralLight sp-card-borderHighlight sp-card-subContainer" }, "children": [ { "elmType": "div", "attributes": { "class": "sp-card-previewColumnContainer" }, "children": [ { "elmType": "div", "attributes": { "class": "sp-card-imageContainer" }, "children": [ { "elmType": "div", "attributes": { "class": "ms-bgColor-neutralLight sp-card-imagePreviewBackground" }, "children": [ { "elmType": "img", "style": { "display": "=if([$Thumbnail] == '', 'none', '')" }, "attributes": { "src": "=[$Thumbnail.serverUrl] + [$Thumbnail.serverRelativeUrl]", "title": "[$Thumbnail.fileName]", "class": "sp-card-imagePreview" } }, { "elmType": "svg", "style": { "display": "=if([$Thumbnail] == '', '', 'none')" }, "attributes": { "preserveAspectRatio": "none", "viewBox": "0 0 210 105", "class": "sp-card-defaultImage ms-bgColor-themeLighter" }, "children": [ { "elmType": "path", "attributes": { "id": "sp-card-defaultImage-path1", "d": "M0 25.7896L126.5 53.8817L96 105H0V25.7896Z" } }, { "elmType": "path", "attributes": { "id": "sp-card-defaultImage-path2", "d": "M96 105L158.7 0H204C207.314 0 210 2.68629 210 6V105H96Z" } } ] }, { "elmType": "svg", "style": { "display": "=if([$Thumbnail] == '', '', 'none')" }, "attributes": { "class": "sp-card-defaultImageOverlay", "viewBox": "0 0 40 40" }, "children": [ { "elmType": "path", "attributes": { "id": "sp-card-defaultImageOverlay-path1", "d": "M 4 4 H 37 V 37 H 4 L 4 4" } }, { "elmType": "path", "attributes": { "id": "sp-card-defaultImageOverlay-path2", "d": "M24.17 21.151L21.66 24.741L17.54 19.191C17.3322 18.914 17.0062 18.751 16.66 18.751C16.3137 18.751 15.9877 18.914 15.78 19.191L9.20997 28.051C8.97126 28.3786 8.93818 28.813 9.12453 29.173C9.31088 29.533 9.68465 29.7567 10.09 29.751H29.91C30.3085 29.7562 30.6769 29.5396 30.866 29.1887C31.0551 28.8378 31.0335 28.411 30.81 28.081L26 21.151C25.7991 20.8407 25.4546 20.6533 25.085 20.6533C24.7153 20.6533 24.3709 20.8407 24.17 21.151Z" } }, { "elmType": "path", "attributes": { "id": "sp-card-defaultImageOverlay-path3", "d": "M28 15.751C29.3807 15.751 30.5 14.6317 30.5 13.251C30.5 11.8703 29.3807 10.751 28 10.751C26.6193 10.751 25.5 11.8703 25.5 13.251C25.5 14.6317 26.6193 15.751 28 15.751Z" } }, { "elmType": "path", "attributes": { "id": "sp-card-defaultImageOverlay-path4", "d": "M4.5 37.251H35.5C36.3284 37.251 37 36.5794 37 35.751V4.75098C37 3.92255 36.3284 3.25098 35.5 3.25098H4.5C3.67157 3.25098 3 3.92255 3 4.75098V35.751C3 36.5794 3.67157 37.251 4.5 37.251ZM4 4.75098C4 4.47483 4.22386 4.25098 4.5 4.25098H35.5C35.7761 4.25098 36 4.47483 36 4.75098V35.751C36 36.0271 35.7761 36.251 35.5 36.251H4.5C4.22386 36.251 4 36.0271 4 35.751V4.75098Z" } } ] } ] } ] } ] }, { "elmType": "div", "attributes": { "class": "sp-card-displayColumnContainer" }, "children": [ { "elmType": "p", "style": { "text-align": "center", "font-size": "18px" }, "attributes": { "title": "[$Title]", "class": "ms-fontColor-neutralPrimary sp-card-content sp-card-highlightedContent" }, "txtContent": "=if ([$Title] == '', '–', [$Title])" } ] }, { "elmType": "div", "attributes": { "class": "sp-card-lastTextColumnContainer" }, "children": [ { "elmType": "p", "style": { "text-align": "center", "vertical-align": "top", "word-break": "normal" }, "attributes": { "title": "[$Description]", "class": "ms-fontColor-neutralPrimary sp-card-content " }, "txtContent": "=if ([$Description] == '', '–', [$Description])" } ] } ] } ] } }Solved15KViews1like12Commentsuse json formatting to set column value, txtcontent, from filter lookup
Hi ... In the json formatting, how do you set txtContent to the result of a "filtered lookup" that is in the json formatting? I am guessing that it is possible to return a lookup in the json formatting, yes? For example ... Current List has a column with a code value. That code value is a column in a source list. The source list also has a name column that contains the value to return to the Current List. All assuming that, fetching the name via the code value "link" and setting txtcontent to that name returned can all be done with json formatting - correct? Or ........ is better list planning needed? Thx for your patience. Kevin834Views0likes0CommentsHyperlink/Picture Column suddenly breaks external images in Gallery/Card Designer
We use a Flow with an API connection to grab image links from an external vendor and populate that data to the Hyperlink or Picture column of a SharePoint list. We then add JSON formatting to display the image links in a Gallery view. The Hyperlink or Picture Column is set to display as Picture. The external images still display fine in the list item view, just not the Gallery/Card view. This was working fine for several months, but something seems to have changed over the last weekend, causing externally linked images in Picture/Hyperlink Columns to break. I setup a simple test list to display this behavior using a public domain image. External Image link: https://www.publicdomainpictures.net/pictures/20000/velka/computer-memory-chips.jpg Internal Image link: https://[mydomain].sharepoint.com/sites/WebDev/SiteAssets/Lists/[LIST-ID/computer-memory-chips.jpg Here is an All Items List View sample: Here is a Gallery/Card Designer View sample of the same list: No JSON used in these examples, just the default Gallery / Card Designer: I've experimented with the Image column, which doesn't seem to exhibit this issue, but unfortunately that column is not available in the Create Items step of the Flow so I assume it cannot be dynamically populated.Solved2.1KViews1like2CommentsSharePoint Online: Apply JSON View formatting using SharePoint REST API
JSON View formatting in SharePoint Online can be a useful tool for customizing the way list/library data is presented to end users. This can help improve the user experience and make it easier for users to understand and interact with the SharePoint list/library data. Learn how to apply JSON View formatting using SharePoint REST API to your SharePoint online lists / Microsoft Lists at: SharePoint Online: Apply JSON View formatting using SharePoint REST API Please consider giving a Like if my post helped you in any way. For SharePoint/Power Platform blogs, visit: Ganesh Sanap Blogs3.8KViews0likes0Comments