cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
syhrh
Dual Super User
Dual Super User

Add Condition in Format Column in SharePoint List

Hi, I have this column that enables the users to cancel their leave requests. I would like to put a time limit for the cancel request button to appear. For example, users can only cancel the request by clicking the column to run the flow is 1 day after the leave request has been made and if it exceeds, it will be invisible. How to do this?

syhrh_0-1662105196844.png

I tried adding Created > Created + 86400000 in the hidden for visibility but it doesn't work.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "button",
  "txtContent": "Cancel Request",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": "{\"id\": \"8634894c-e0c0-4b9f-8e99-e4cafb5bb802\"}"
  },
  "style": {
    "background-color": "#E43333",
    "outline": "transparent",
    "border-color": "transparent",
    "color": "white",
    "visibility": "=if([$Status] == 'Rejected' || [$Status] == 'Cancelled' || [$Created] > [$Created] + 86400000,'hidden','visible')"
  }
}

 

Thank you.

2 ACCEPTED SOLUTIONS

Accepted Solutions
NandiniBhagya20
Solution Sage
Solution Sage

Hi,

 

I think you should compare the date ([$Created] + 86400000) with now instead of comparing it be created date. Can you please try below mentioned formula - 

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "button",
  "txtContent": "Cancel Request",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": "{\"id\": \"8634894c-e0c0-4b9f-8e99-e4cafb5bb802\"}"
  },
  "style": {
    "background-color": "#E43333",
    "outline": "transparent",
    "border-color": "transparent",
    "color": "white",
    "visibility": "=if([$Status] == 'Rejected' || [$Status] == 'Cancelled' || toLocaleDateString(@now) > toLocaleDateString([$Created] + 86400000),'hidden','visible')"
  }
}

 


Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

View solution in original post

Hi,

You will have to add the column in your views. If you will not add the column in your list view, it will not be visible/usable 


Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

View solution in original post

4 REPLIES 4
NandiniBhagya20
Solution Sage
Solution Sage

Hi,

 

I think you should compare the date ([$Created] + 86400000) with now instead of comparing it be created date. Can you please try below mentioned formula - 

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "button",
  "txtContent": "Cancel Request",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": "{\"id\": \"8634894c-e0c0-4b9f-8e99-e4cafb5bb802\"}"
  },
  "style": {
    "background-color": "#E43333",
    "outline": "transparent",
    "border-color": "transparent",
    "color": "white",
    "visibility": "=if([$Status] == 'Rejected' || [$Status] == 'Cancelled' || toLocaleDateString(@now) > toLocaleDateString([$Created] + 86400000),'hidden','visible')"
  }
}

 


Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

Hi @NandiniBhagya20, it works fine but the formula works only when I show the column "Created". If not, it won't be applicable. Can I display the column but the users won't be able to see it?

Hi,

You will have to add the column in your views. If you will not add the column in your list view, it will not be visible/usable 


Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

@NandiniBhagya20 Okay, thank you.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,689)