cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
jeanwang
Level: Powered On

conditional formatting in Json

Hi,

 

I want to add a conditional formatting code to column Kickoff Complete Date. If the column is blank and today's date is greater than [Kickoff Deadline], I would like the Kickoff Complete Date to be highlighted. I understand this need to be done by inserting a Json code in column setting. But I have no clue about Json. Can someone help please?

 

conditional formatting.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: conditional formatting in Json

Hey @jeanwang 

 

In that case, can you try to update the formatting as:
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "attributes": {
    "class": "=if([$KickoffDeadline]<=@now,if(toString(@currentField) == '','sp-field-severity--warning', ''),'')"
  },
  "children": [
    {
      "elmType": "span",
      "style": {
        "display": "inline-block",
        "padding": "0 4px"
      },
      "attributes": {
        "iconName": ""
      }
    },
    {
      "elmType": "span",
      "txtContent": "@currentField"
    }
  ]
}
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
4 REPLIES 4
Super User
Super User

Re: conditional formatting in Json

Hey @jeanwang 

 

Yes. You can do that with the column formatting in JSON on the SP List. Try using the below schema: 

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "attributes": {
    "class": "=if([$KickoffDeadline]<=@now,'sp-field-severity--warning', '')"
  },
  "children": [
    {
      "elmType": "span",
      "style": {
        "display": "inline-block",
        "padding": "0 4px"
      },
      "attributes": {
        "iconName": ""
      }
    },
    {
      "elmType": "span",
      "txtContent": "@currentField"
    }
  ]
}

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

jeanwang
Level: Powered On

Re: conditional formatting in Json


@yashag2255 wrote:

Hey @jeanwang 

 

Yes. You can do that with the column formatting in JSON on the SP List. Try using the below schema: 

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "attributes": {
    "class": "=if([$KickoffDeadline]<=@now,'sp-field-severity--warning', '')"
  },
  "children": [
    {
      "elmType": "span",
      "style": {
        "display": "inline-block",
        "padding": "0 4px"
      },
      "attributes": {
        "iconName": ""
      }
    },
    {
      "elmType": "span",
      "txtContent": "@currentField"
    }
  ]
}

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!


Thank you very much for the scheme. It looks like you code didn't mention the first condition that the current column, i.e., [Kickoff Complete Date] should be blank.

 

Probably it will help if I explain my need in more detail. I aim to create a project plan based on SharePoint list. Each time an activity is completed, the owner needs to fill the [complete date], if the [complete date] column is blank and the deadline data is past, I would like the blank column [complete date] to be highlighted. In this way, we know at which step the project is delayed. So in my case , the condition will be:

if current column [Kickoff Complete Date] is blank,

&

column [Kickoff Deadline] <now

highlight current column [Kickoff Complete Date]

end if

 

Can you please help with the schema?

 

Thank you!

 

Super User
Super User

Re: conditional formatting in Json

Hey @jeanwang 

 

In that case, can you try to update the formatting as:
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "attributes": {
    "class": "=if([$KickoffDeadline]<=@now,if(toString(@currentField) == '','sp-field-severity--warning', ''),'')"
  },
  "children": [
    {
      "elmType": "span",
      "style": {
        "display": "inline-block",
        "padding": "0 4px"
      },
      "attributes": {
        "iconName": ""
      }
    },
    {
      "elmType": "span",
      "txtContent": "@currentField"
    }
  ]
}
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
jeanwang
Level: Powered On

Re: conditional formatting in Json

Thank you  so much! It works perfectly this time. This give me a start on Json as well, I will try to learn a bit about Json myself so that I can configure the objects and operators myself in future.

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 475 members 4,618 guests
Please welcome our newest community members: