Display different flow buttons in sharepoint list with time condition
Domanda
I have a list where an item can have different statuses (Draft, Planned, Updated and finished) I wanted 3 different flows to be able to run, so the buttons are:
- When Draft: [Send item]
- When Updated: [Send Update]
- When Planned: [Finish]
- When Finished: Field is empty
I have a part code assembled from various sources, and this works perfectly, so I hope I can already help someone with this
{
"elmType": "div",
"children": [
{
"elmType": "button",
"txtContent": "Send Item",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"}"
},
"style": {
"background-color": "#bf279b",
"color": "white",
"border-radius": "10px",
"margin-top": "2px",
"padding": "6px",
"position": "absolute",
"left": "0",
"cursor": "pointer",
"visibility": {
"operator": "?",
"operands": [
{
"operator": "==",
"operands": [
"[$Status]",
"Draft"
]
},
"visible",
"hidden"
]
}
}
},
{
"elmType": "button",
"txtContent": "Send Update",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"}"
},
"style": {
"background-color": "#279bbf",
"color": "white",
"border-radius": "20px",
"margin-top": "2px",
"padding": "6px",
"position": "absolute",
"left": "0",
"cursor": "pointer",
"visibility": {
"operator": "?",
"operands": [
{
"operator": "==",
"operands": [
"[$Status]",
"Updated"
]
},
"visible",
"hidden"
]
}
}
},
{
"elmType": "button",
"txtContent": "Finish",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"}"
},
"style": {
"background-color": "#279bbf",
"color": "white",
"border-radius": "20px",
"margin-top": "2px",
"padding": "6px",
"position": "absolute",
"left": "0",
"cursor": "pointer",
"visibility": {
"operator": "?",
"operands": [
{
"operator": "==",
"operands": [
"[$Status]",
"Planned"
]
},
"visible",
"hidden"
]
}
}
}
]
}
Now I want the last button (Finish) only appear when the end date has passed.
So that condition needs to be [$Status] = "Planned" AND [$DateEnd] is "passed xx minutes ago"
.
The line I already got working on its own in the conditional formatting is this (15 minutes after EndDate
the line gets a different color)
if([$DateEnd] <= (@now - 900000)
But I can't get these combined in my flow button json. Maybe in that code is also room for improvement or another way to accomplish this scenario?
Any help would more than appreciated.
Soluzione
Try changing visibility
property in last code block to:
"visibility": "=if([$Status] == 'Planned' && [$DateEnd] <= (@now - 900000), 'visible', 'hidden')"
OR
"display": "=if([$Status] == 'Planned' && [$DateEnd] <= (@now - 900000), 'block', 'none')"