0

enter image description here

First of all, apologies if this horse has been beaten before but I can't find anything so far to help me out.

I'm trying to do some conditional formatting of a column in a SP list.

One of the columns in the list is Name (it would appear that this is a default column name). For whatever reason I'm unable to get the following JSON to see a Name column. I've tried [$Name], which 'seems' like it should work, but even though there is a Name value in each row of the list, the JSON is never picking it up.

Can someone throw me a bone here?

Here's a JSON snippet of what I'm attempting:

{
  "$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
  "elmType": "a",
  "txtContent": "=if(indexOf(toLowerCase([$Name]),'pink') != -1, 'STATUS REPORT','')",
  "style": {
    "color": "blue"
  },
  "attributes": {
    "target": "_blank",
    "href": "=if(indexOf(toLowerCase([$Name]),'pink') != -1, <someurl>, '')"
  }
}
1
1

According to the official documentation,

You can use this context([$FieldName]) to reference the values of other fields within the same row by specifying the internal name of the field surrounded by square brackets and preceded by a dollar sign: [$InternalName].

So, you need to use the internal name of your Name column in your JSON code.

Check below URL to find out the internal name of SharePoint column:

Find the internal name of SharePoint column.

Note: If you are trying to use Name (filename) column in document library then its internal name is FileLeafRef. So you can use it like:

{
  "$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
  "elmType": "a",
  "txtContent": "=if(indexOf(toLowerCase([$FileLeafRef]),'pink') != -1, 'STATUS REPORT','')",
  "style": {
    "color": "blue"
  },
  "attributes": {
    "target": "_blank",
    "href": "=if(indexOf(toLowerCase([$FileLeafRef]),'pink') != -1, 'https://www.google.com', '')"
  }
}
1
  • 1
    Perfect! That's exactly what I was looking for. I can't find the documentation for this, it's like looking for water in the desert sometimes when it comes to Sharepoint's little details. I appreciate the assistance! – Jeff Bryant Dec 22 '19 at 5:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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