0

Can a condition be added to the multiple-line text column so that if it includes a semicolon, it sends a notification, changes the color, or something similar?

enter image description here

1
  • Is this a plain text column or rich text column? Can you add screenshot of column settings page? Commented Apr 30 at 5:29

2 Answers 2

1
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "@currentField",
  
  "style": {
          "background-color": "=if(indexOf(@currentField,';') != -1, '#00F','')",
          "color": "=if(indexOf(@currentField,';') != -1, '#FFF','')"
       }
}

enter image description here

1

You cannot send notification by default/automatically using SharePoint Online JSON formatting. However, you can change the font color of text or background color of cell, etc. using JSON formatting based on conditions.

Example:

Below JSON changes the color of text, add "bold" formatting to text and changes background color of the column cell based on condition:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
    "padding-left": "5px",
    "font-weight": "=if(indexOf(@currentField, ';') >= 0, 'bold', '')",
    "background-color": "=if(indexOf(@currentField, ';') >= 0, 'red', '')",
    "color": "=if(indexOf(@currentField, ';') >= 0, 'white', '')"
  }
}

Output:

enter image description here

You can find detailed steps to apply JSON column formatting to your SharePoint list column in the Microsoft official documentation at: Use JSON column formatting to customize SharePoint lists.


Update from comments:

You can use JSON like below to show notification text in same column cell:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "=if(indexOf(@currentField, ';') >= 0, @currentField + '\n\nPlease remove semicolons from this column value', @currentField)",
  "style": {
    "padding-left": "5px",
    "font-weight": "=if(indexOf(@currentField, ';') >= 0, 'bold', '')",
    "background-color": "=if(indexOf(@currentField, ';') >= 0, 'red', '')",
    "color": "=if(indexOf(@currentField, ';') >= 0, 'white', '')"
  }
}

Output:

enter image description here

4
  • That worked perfectly. Can we also add a notification to say you need to remove the semicolon?
    – Harris
    Commented May 1 at 0:44
  • You mean notification via email or notification text in same column cell in SharePoint list? Commented May 1 at 4:21
  • Notification text in the same column?
    – Harris
    Commented May 1 at 4:36
  • 1
    Yes, you can do that using JSON column formatting. Check updated answer. Let me know if it works for you. Commented May 2 at 5:42

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.