Add a Flow button in a SharePoint library
-
13-02-2021 - |
Question
I have recently added a Flow button in a SharePoint Library. I found the code on internet (I have no experience in JSON).
I would like the button to be visible if:
- Document status (choice column) is different than Approved
- Approvers (person column) is not empty
- Ready for Approval (boolean column) is True
I could implement only one condition: Document status (choice column) is different than Approved
But I wonder how can I add the other 2 conditions?
Any help would more than appreciated.
The code looks like this:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "span",
"style": {
"color": "#001f00"
},
"children": [
{
"elmType": "button",
"style": {
"border": "light",
"background-color": "Orange",
"color": "#001f00",
"cursor": "pointer",
"visibility": {
"operator": "?",
"operands": [
{
"operator": "!=",
"operands": [
"[$Document_x0020_status]",
"Approved",
]
},
"visible",
"hidden"
]
}
},
"txtContent": "Send to Approval",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"53c665d0-ce12-4148-aa5a-c7202557ea78\"}"
}
}
]
}
Solution
Try using this:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "span",
"style": {
"color": "#001f00"
},
"children": [
{
"elmType": "button",
"style": {
"border": "light",
"background-color": "Orange",
"color": "#001f00",
"cursor": "pointer",
"display": "=if([$Document_x0020_status]!='Approved' && [$Approvers] && [$Ready for Approval],'block','none')"
},
"txtContent": "Send to Approval",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"53c665d0-ce12-4148-aa5a-c7202557ea78\"}"
}
}
]
}
Note: You need to use the internal name of your columns in JSON.
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange