web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Add Condition in Forma...
Power Apps
Answered

Add Condition in Format Column in SharePoint List

(0) ShareShare
ReportReport
Posted on by 997 Super User 2024 Season 1

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.

Categories:
  • Verified answer
    NandiniBhagya20 Profile Picture
    4,667 Super User 2024 Season 1 on at

    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')"
     }
    }

     

  • syhrh Profile Picture
    997 Super User 2024 Season 1 on at

    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?

  • Verified answer
    NandiniBhagya20 Profile Picture
    4,667 Super User 2024 Season 1 on at

    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 

  • syhrh Profile Picture
    997 Super User 2024 Season 1 on at

    @NandiniBhagya20 Okay, thank you.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 258

#3
Mohsin Ali Profile Picture

Mohsin Ali 231

Last 30 days Overall leaderboard