Feb 06 2023 08:29 AM - edited Feb 06 2023 09:17 AM
Hello, I am having trouble with the code below. This code is adjusted from this header formatting. Here are the issues I am having:
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'))"
}
}
]
}
]
}
]
}
]
}
Feb 06 2023 08:50 AM
@LaMakiry I run away from 200 lines of JSON as there is often a way to do it with far less code. Do you have a screenshot of the sort of thing you are trying to achieve?
Feb 06 2023 09:16 AM
@RobElliott Sorry! I thought including the entire code would help. Fig 1 is my header. I will break it down here:
Manager Approval-->Approved-->GreenCircle-->Not Approved-->RedCircle
Ethics Approval: Single Line Text. Just need to get rid of the extra code without jeopardizing the entire code
SNL Approval-->When someone enters their name in this "Person Group" column, it should turn green circle, otherwise, it should be a yellow circle.
I will include code snippets of each bullet if that helps.
Fig 1.
{
"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",
"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",
"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'))"
}
}