JSON If Statement
4 TopicsJSON If Statement
Hi I have an If Statement that conditionally formats the background based on a date as follows; "attributes": { "class": "=if(@currentField <= @now,'sp-field-severity--blocked', if(@currentField <= @now + 7776000000, 'sp-field-severity--warning', if(@currentfield >= @now + 78624000000, 'sp-field-severity--good','sp-field-severity--good')))" }, I need to amend this to add an additional criteria based on a text value and tried adding if(@currentField == 'Failed', 'sp-field-severity--blocked' but its not working, any help on this appreciated.Solved6.2KViews0likes5CommentsConditional 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.2KViews0likes3CommentsJSON 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'))" } } ] } ] } ] } ] }2KViews0likes2CommentsJSON Column Formatting help with Condition statement for displaying Hyperlink alternate txt
I have a SharePoint list, which I have a single line of text column that will contain an URL link. To start with this column is blank and does not show on the new for item form. It gets populated by power automate when the flow creates a file in a whiteboard document library and and the next step in the flow after creating the document in the "Whiteboard" document library is to update the URL single line of text column with the link to the file it created in the previous step if the flow. I would like to display this column as a clickable link using JSON column formatting and I have found the following code to display the URL as a link and the alternate text as "whiteboard" and it works. However, if the field is blank I would like to leave the field displayed as blank, instead of "Whiteboard". Right now while it works, it displays "Whiteboard" for every item, even if the field is blank before the flow triggers and has a chance to populate it. I would like to modify the code I am using to make the field show nothing in the column if the column is left blank and then once the flow populates the column, the have it show the alternate text as "whiteboard". Can anybody suggest how to modify this so it will still display "Whiteboard" if the the column is not blank, but if the column is blank, then to display the column as blank? OR Can somebody suggest how to modify the code with an IF statement where it shows the txtContent as "whiteboard" only if the column is not null otherwise shows the txtContent as "Creating" Here is the code I am using: { "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "a", "attributes": { "href": "@currentField", "target": "_blank" }, "txtContent": "Whiteboard" }Solved6.2KViews0likes3Comments