question

RodmanStuhlmuller-6443 avatar image
0 Votes"
RodmanStuhlmuller-6443 asked MichaelRay-9202 edited

Is there a way to reference columns in SharePoint lists when conditional formatting?

I want to highlight dates when they are past due. (Completion date IS AFTER Due date). Right now my only options for the date is Today or a specific date, but I want to be able to choose another column.

office-sharepoint-online
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello - I am REALLY trying to figure out how to use JSON to update a SharePoint Online list column BASED ON A CHANGE TO A SEPARATE COLUMN.

In other words, If my list has a column called "Completion" and it is a choice column ranging from 0% to 100% (0, 25, 50, 75, 100) and a second column called "Status" with choices of "Not Started," "On Track,""Attention," "At Risk," and "Complete."

How do I use JSON in such a way that, when the Completion column is changed to (for example) "50%," the "Status" column will automatically change to ""Attention?"

Any help would be greatly appreciated.

Mike

0 Votes 0 ·

1 Answer

JoyZ avatar image
0 Votes"
JoyZ answered JoyZ commented

@RodmanStuhlmuller-6443,

We could use the [$FieldName] syntax to look at the value inside another field in column formatting.

FieldName is assumed to be the internal name of the field.

Simple test for your reference:

  1. Find the internal name of another field via list settings>click on the specified column under Columns option, check the url of the column to get the internal name:
    List item


  2. Format the "Completion date" column as shown below:

118475-image.png

Code:

 {
 "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
 "elmType": "div",
 "txtContent": "@currentField",
 "attributes": {
 "class": "=if(@currentField >= [$Duedate], 'ms-fontColor-orange ms-fontWeight-bold', '')"
   } 
 }

More information for your reference:

https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting#formatting-an-item-when-a-date-column-is-before-or-after-todays-date-advanced


If an Answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



image.png (15.9 KiB)
image.png (50.9 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@RodmanStuhlmuller-6443,

I’m checking how the things are going on about this issue.

Please feel free to reply if there is any update.

0 Votes 0 ·