JSON formatting
25 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.4KViews0likes1CommentJSON 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. Kevin834Views0likes0CommentsSharePoint 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.8KViews0likes0CommentsSharePoint List Calendar View Conditional Formatting Not Displaying for Everyone
Good afternoon, I have an odd issue I'm struggling with. I've implemented some JSON code that changes the color of a Sharepoint calendar view event based on the event type. Most people see the color coding, however some people see all event types as one color (red). At first I thought it had to do with the level of MS access each user had (the first to flag it was an outside consultant), but a few others also experience this issue and their access levels range from Associate through Director. Has anyone else experienced this issue and know how to fix it? Thank you.971Views0likes0CommentsJSON Header Formatting Issue
Hello, I am having trouble with the code below. This code is adjusted from this header formatting. Here are the issues I am having: Manager Approval-->Not Approved: I would like for this to be red. The entire circle disappears when I try to adjust the "Not Approved" code Ethics Approval: This code works just fine. I would like to know how to delete the HR approval codes without jeopardizing the ethics approver code. For example, when I remove everything that has to do with HR Approval, the entire circle disappears (Fig 1) SNL Approval: This circle stays green even if their is nothing in the column. If someone's name is entered in the column "SNL Approver Name", then it should be green, like Ethics Approval. I tried using the same code as the Ethics Approval but it does not work. (The approver name column for this one is "Person Group' while Ethics is "Single Line Text") I would also like to get rid of the unnecessary HR approval codes (circle disappears when adjusting it) Fig. 1 { "elmType": "div", "attributes": { "iconName": "=if([$Ethics_Approver_Name] != '' ,'CompletedSolid' ,'CircleShapeSolid'))", "class": "=if([$Ethics_Approver_Name] != '' ,'ms-fontSize-42 ms-fontColor-green',if([$Ethics_Approver_Name] == '' ,'ms-fontSize-42 ms-fontColor-yellow','ms-fontSize-42 ms-fontColor-neutralTertiary'))" } { "elmType": "div", "style": { "margin": "5px", "width": "100%", "height": "160px", "border": "2px dashed", "padding": "10px", "display": "flex", "flex-direction": "column", "align-items": "center" }, "children": [ { "elmType": "div", "txtContent": "Project Initiation (PI)", "attributes": { "class": "ms-fontSize-28 ms-fontWeight-bold" } }, { "elmType": "div", "style": { "display": "flex", "justify-content": "center", "width": "100%" }, "children": [ { "elmType": "div", "style": { "display": "flex", "flex-direction": "row" }, "children": [ { "elmType": "div", "style": { "width": "140px", "display": "flex", "flex-direction": "column", "align-items": "center", "margin": "20px" }, "children": [ { "elmType": "div", "txtContent": "Manager Approval", "style": { "margin-bottom": "5px" }, "attributes": { "class": "ms-fontSize-15" } }, { "elmType": "div", "attributes": { "iconName": "=if([$Manager_Approval] == 'Approved' ,'CompletedSolid', if([$AD_Approval] == 'Not Approved' ,'CompletedSolid' , 'CircleShapeSolid'))", "class": "=if([$Manager_Approval] == 'Approved' ,'ms-fontSize-42 ms-fontColor-green', if([$AD_Approval] == 'Approved' ,'ms-fontSize-42 ms-fontColor-green',if([$AD_Approval] == 'Pending AD Approval' ,'ms-fontSize-42 ms-fontColor-yellow',if([$AD_Approval] == 'Not Approved' ,'ms-fontSize-42 ms-fontColor-yellow',if([$Manager_Approval] == 'Pending Manager Approval' , 'ms-fontSize-42 ms-fontColor-yellow' ,if([$Manager_Approval] == 'Not Approved' , 'ms-fontSize-42 ms-fontColor-red' , 'ms-fontSize-42 ms-fontColor-neutralTertiary'))))))" } } ] }, { "elmType": "div", "style": { "width": "80px", "display": "flex", "flex-direction": "column", "align-items": "center", "margin-top": "50px" }, "txtContent": "---------->", "attributes": { "class": "ms-fontSize-16" } }, { "elmType": "div", "style": { "width": "120px", "display": "flex", "flex-direction": "column", "align-items": "center", "margin": "20px" }, "children": [ { "elmType": "div", "txtContent": "🧐AD Approval", "style": { "margin-bottom": "5px" }, "attributes": { "class": "ms-fontSize-15" } }, { "elmType": "div", "attributes": { "iconName": "=if([$AD_Approval] == 'Approved' ,'CompletedSolid' , 'CircleShapeSolid')", "class": "=if([$AD_Approval] == 'Approved' ,'ms-fontSize-42 ms-fontColor-green',if([$AD_Approval] == 'Pending AD Approval' , 'ms-fontSize-42 ms-fontColor-yellow' ,if([$AD_Approval] == 'Not Approved' , 'ms-fontSize-42 ms-fontColor-red' , 'ms-fontSize-42 ms-fontColor-neutralTertiary'))" } } ] }, { "elmType": "div", "style": { "width": "80px", "display": "flex", "flex-direction": "column", "align-items": "center", "margin-top": "50px" }, "txtContent": "---------->", "attributes": { "class": "ms-fontSize-16" } }, { "elmType": "div", "style": { "width": "140px", "display": "flex", "flex-direction": "column", "align-items": "center", "margin": "20px" }, "children": [ { "elmType": "div", "txtContent": "Ethics Approval", "style": { "margin-bottom": "5px" }, "attributes": { "class": "ms-fontSize-15" } }, { "elmType": "div", "attributes": { "iconName": "=if([$Ethics_Approver_Name] != '' ,'CompletedSolid' ,if([$ApprovalStatus] == 'Rejected by HR' ,'CompletedSolid' , if([$ApprovalStatus] == 'Pending HR Approval' ,'CompletedSolid' ,'CircleShapeSolid')))", "class": "=if([$Ethics_Approver_Name] != '' ,'ms-fontSize-42 ms-fontColor-green', if([$Ethics_Approver_Name] == '' ,'ms-fontSize-42 ms-fontColor-yellow', if([$ApprovalStatus] == 'Pending HR Approval' ,'ms-fontSize-42 ms-fontColor-green',if([$ApprovalStatus] == 'Rejected by HR' ,'ms-fontSize-42 ms-fontColor-green',if([$ApprovalStatus] == 'Pending Manager Approval' , 'ms-fontSize-42 ms-fontColor-yellow' ,if([$ApprovalStatus] == 'Rejected by Manager' , 'ms-fontSize-42 ms-fontColor-red' , 'ms-fontSize-42 ms-fontColor-neutralTertiary')))))" } } ] }, { "elmType": "div", "style": { "width": "80px", "display": "=if([$Are_x0020_you_x0020_using_x0020_] =='CSI','block', 'none')", "flex-direction": "column", "align-items": "center", "margin-top": "50px" }, "txtContent": "---------->", "attributes": { "class": "ms-fontSize-16" } }, { "elmType": "div", "style": { "width": "120px", "display": "=if([$Are_x0020_you_x0020_using_x0020_] =='CSI','block', 'none')", "flex-direction": "column", "align-items": "center", "margin": "20px" }, "children": [ { "elmType": "div", "txtContent": "SNL Approval", "style": { "display": "=if([$Are_x0020_you_x0020_using_x0020_] =='CSI','block', 'none')", "margin-bottom": "5px" }, "attributes": { "class": "ms-fontSize-15" } }, { "elmType": "div", "attributes": { "iconName": "=if([$SNL_Approver_Name] != '' ,'CompletedSolid' , 'CircleShapeSolid')", "class": "=if([$SNL_Approver_Name] != '' ,'ms-fontSize-42 ms-fontColor-green',if([$ApprovalStatus] == 'Pending HR Approval' , 'ms-fontSize-42 ms-fontColor-yellow' ,if([$ApprovalStatus] == 'Rejected by HR' , 'ms-fontSize-42 ms-fontColor-red' , 'ms-fontSize-42 ms-fontColor-neutralTertiary'))" } } ] } ] } ] } ] }2KViews0likes2CommentsColumn Formatting Data Bars under Text
Hi everyone! I am trying to optimize a list of tasks and would love a choice column with 5 choices outlining the latest status on the projects that are populating the list. I.e. 5 "milestones" along the way of completing the task that can be signified in the list. I would love that column to be formatted with data bars that show different percentages for each milestone (e.g. 15,30,50,65,85%). I am sure I could built a calculated column to show that progress-bar by linking it to the choice-column, perhaps even transferring that formatting back to the choice column itself, but that seems like an unnecessary workaround. Unfortunately, my JSON skills are not the best, so any pointers would be appreciated.Solved2.7KViews0likes3Comments