2

I'm fairly new to SharePoint JSON. I have a simple JSON to change the value of a column based on the value of another column:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "=if([$Persona] == 'Developer', 'A Developer is any person who has a responsibility to write code for application building, continuous delivery, automated testing, data analytics or vulnerability reviews.', 'N/A')"
}

Even though an item in the list has Developer as the value of the Persona column, the alternate text (N/A) is always displayed.

What am I doing wrong here? Also, is it possible to do an if else in SP JSON?

6
  • You have to use the correct internal name of Persona column in the JSON. Follow this article to get the correct internal name: ganeshsanapblogs.wordpress.com/2023/04/17/…. Let me know if this works for you. Commented Oct 29, 2024 at 14:38
  • What is the column/data type of "Persona" column? Commented Oct 29, 2024 at 14:40
  • Persona column is just a single line text type Commented Oct 29, 2024 at 17:50
  • When I follow the instructions on the linked page, the URL after filtering is: xxxxxxx.sharepoint.com/sites/DevSecOps/Lists/… the filter field is listed as sortField=LinkTitle... The filter works but if I replace [$Persona] with [$LinkTitle] I get the same error. Commented Oct 29, 2024 at 18:00
  • The problem was with the column. I had renamed the Title column to Persona. Creating a new column and rewriting the code with that column name worked. Thanks for putting me on the right track. Commented Oct 29, 2024 at 18:05

1 Answer 1

1

You have to use the correct internal name of your SharePoint list columns in the JSON formatting.

If you have renamed and using SharePoint default Title column, you have to use [$Title] in the JSON.

For any other custom columns you created in the SharePoint list, you can get correct internal name by following this article: How to find the Internal name of columns in SharePoint Online?.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.