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?
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.
Solved! Go to Solution.
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')"
}
}
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
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')"
}
}
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