Forum Discussion
Peter_K
Apr 17, 2019Copper Contributor
Conditional JSON formatting of button in SharePoint List
Hi everybody I am looking for a solution for a formatting problem in one of my sharepoint columns. In one column I have a button which triggers a flow. I am aiming for a visability of the ...
- Apr 18, 2019
{
"elmType": "button",
"txtContent": "Get Approved",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\":\"86dfdf10-8d99-4914-8e98-fe4b21ed7e34\"}"
},
"style": {
"background-color": "purple",
"color": "white",
"visibility": "=if(([$ModerationStatus] == 'Pending') && ([$DocumentType] == 'Offer'),'visible','hidden')"
}}
check this sample .. I got rid of the Operator and used a simple if statement. only change to visibility property.
rolanddaane
Jun 20, 2021Copper Contributor
Hi,
I'm trying something similar, but can't get it to work.
I want the button to show if the value of column ShareBim360 = Yes.
In my case it's just ignoring and showing on every row.....
Any ideas?
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "button",
"txtContent": "Share to Bim360",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"bce75e04-998b-4600-b829-7370d6a2ee15\"}"
},
"style": {
"background-color": "#468259",
"color": "white",
"visibility": "=if(([$ShareBim360] == 'Yes'),'hidden','visible')"
}
}
I'm trying something similar, but can't get it to work.
I want the button to show if the value of column ShareBim360 = Yes.
In my case it's just ignoring and showing on every row.....
Any ideas?
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "button",
"txtContent": "Share to Bim360",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"bce75e04-998b-4600-b829-7370d6a2ee15\"}"
},
"style": {
"background-color": "#468259",
"color": "white",
"visibility": "=if(([$ShareBim360] == 'Yes'),'hidden','visible')"
}
}
- RobElliottJun 20, 2021Silver Contributor
rolanddaane your if statement on the visibility line is the wrong way round, it should be:
"visibility": "=if(([$ShareBim360] == 'Yes'),'visible', 'hidden')"Rob
Los Gallardos
Intranet, SharePoint, Website and Power Platform Manager (and classic 1967 Morris Traveller driver)- rolanddaaneJun 20, 2021Copper ContributorHi mate, thanks!
I took an example of yours, and I really like the buttons!
If I use the below the buttons shoe on no line, even if the value of ShareBim360 contains Yes
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "button",
"txtContent": "Share to Bim360",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"bce75e04-998b-4600-b829-7370d6a2ee15\",\"headerText\":\"All Things REI\",\"runFlowButtonText\":\"Publish Now\"}"
},
"style": {
"background-color": "#008082",
"color": "white",
"border-radius": "0 15px",
"visibility": "=if(([$ShareBim360] == 'Yes'),'visible', 'hidden')"
}
}- rolanddaaneJun 20, 2021Copper ContributorBTW, On the column Filename I have something similat, and that does work:
the filename is not allowed to have 2 minus signs (eg --)
The filename that's generated based on metadata from user is formatted like BC1234-BAM-XX-YY-ZZ-A-001.docx and all the elements must be present before someone can trigger the approval flow.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField",
"style": {
"color": "=if(indexOf(@currentField, '--' )<1, 'Green', if(indexOf(@currentField, '--' )>0, 'grey', 'black'))",
"font-size": "1.12em"
}
}