1

I am very new to JSON. I have a document library, and I am trying to have a "Status" column populated with "Acknowledged" if two columns show a date, or "Unacknowledged" if they show no date.

Am I on the right track or completely off base?

{
   "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
   "elmType": "div",
   "txtContent": "=if([$Employee Acknowledgement] =='',[$Status]= 'Unacknowledged'"
}

1 Answer 1

0

Try using SharePoint column formatting JSON like:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "=if(Number([$EmployeeAcknowledgement]) == 0 || Number([$SecondAcknowledgement]) == 0,'Unacknowledged','Acknowledged')",
  "style": {
    "color": "=if(Number([$EmployeeAcknowledgement]) == 0 || Number([$SecondAcknowledgement]) == 0,'red','green')",
    "font-weight": "bold"
  }
}

Where [$EmployeeAcknowledgement] and [$SecondAcknowledgement] is an internal name of your date columns in SharePoint list in this format: [$InternalNameOfColumn]. You can get the internal name of your SharePoint list columns by following this article: How to find the Internal name of columns in SharePoint Online?.

Here I have used Number([$SecondAcknowledgement]) == 0 to check if SharePoint date column is blank or not. You can find other ways to check if SharePoint date & time column is empty or not at: SharePoint JSON formatting: Check if date & time column is blank/empty.

Output:

enter image description here

Note:

  1. You have to use correct internal names of your columns in above JSON.
  2. You have to apply this JSON column formatting for your "Status" column.
  3. SharePoint JSON formatting only customizes the display of list column. It does not change the actual value of the column: Use column formatting to customize SharePoint.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.