Jan 07 2021 08:19 PM
Hi you clever people,
I am trying to get a DUE DATE column in my list to show red when the BID STATUS is 'Go', and the DUE DATE is within 5 days from now. To test it, we coded it so that it would colour any future dates. However, it's not colouring anything. Here is the code we have:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"attributes": {
"class": "=if(((Number([$Submission_x0020_due_x0020_date]) - Number(@now)) > 0) && [$Bid_x0020_status] == 'Go','sp-css-backgroundColor-blockingBackground50', '')"
},
"children": [
{
"elmType": "span",
"style": {
"display": "inline-block",
"padding": "0 4px"
}
},
{
"elmType": "span",
"txtContent": "@currentField"
}
]
}
Can anyone advise what we are doing wrong? And why none of the dates are showing red?
Jan 07 2021 09:22 PM - edited Apr 17 2023 06:19 AM
@MonsoonDesign Try using below JSON code, it should work for you:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"attributes": {
"class": "=if(([$Submission_x0020_due_x0020_date] >= @now && [$Submission_x0020_due_x0020_date] <= @now + 432000000) && [$Bid_x0020_status] == 'Go', 'sp-css-backgroundColor-blockingBackground50', '')"
},
"children": [
{
"elmType": "span",
"style": {
"display": "inline-block",
"padding": "0 4px"
}
},
{
"elmType": "span",
"txtContent": "@currentField"
}
]
}
Make sure you are using correct internal name of Submission due date and Bid status columns.
Microsoft documentation: Use column formatting to customize SharePoint
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
For SharePoint/Power Platform blogs, visit: Ganesh Sanap Blogs
May 04 2022 08:27 PM
May 19 2023 12:35 AM
@royk2022 Use JSON like below in SharePoint JSON view formatting:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
"additionalRowClass": "=if([$Modified] < addDays(@now,-7), 'sp-field-severity--severeWarning', '')"
}
Make sure you have shown/included Modified column in list view.
Output:
Please consider giving a Like if my post helped you in any way.