I am completely all new to this.
I have a simple SharePoint list recording training.
What coding would I need to write in, to achieve the following:
- blank fields - color red
- anything else with a date in goes green.
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityFor your requirements, you have to use the Column formatting in SharePoint. Follow steps given here in official documentation to open column formatting settings & add below JSON code.
You can use simple JSON like below to format your date columns:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"attributes": {
"class": "=if(Number(@currentField) == 0, 'sp-field-severity--blocked', 'sp-field-severity--good')"
}
}
Output:
See other ways to check if date column is empty at: SharePoint JSON formatting: Check if date & time column is blank/empty
Official documentation: Use column formatting to customize SharePoint
You can use column formatting to meet your needs in SharePoint Online.
Please following steps:
1.Go to the list as a site admin
2.Select the "Date and time" column >> Column settings >> Format this column
3.On the Format Column windows, click on "Advanced mode" link
4.Please use the below JSON code
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"attributes": {
"class": "=if(Number(@currentField) == 0, 'sp-field-severity--blocked','sp-field-severity--good')"
}
}
5.Click "Save"