01-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?
01-07-2021 09:22 PM
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 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.