cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

SharePoint Online column json formatting on folders issue

Hello,

 

I have an SP list where the user is allowed to create folders and then add list item inside those folders. I have a flow attached to this list which gets triggered manually. I have added json formatting to show/hide the Manual trigger button based on the Content Approval status.

 

Issue:

The issue I am having is that the json formatting also shows up on the folders created in the list. How can I only show the json formatting on list items and skip if there is a folder

 

Here is the json I have written so far.

 

{
"elmType": "button",
"style": {
"border": "solid",
"background-color": "white",
"color": "#0078d7",
"cursor": "pointer",
"visibility": "=if(([$_ModerationStatus] == 'Pending'),'visible','hidden')"
},
"txtContent": "Click to begin review",
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"flowID\"}"
}
}

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

I think I figured out the solution. I added a condition to see if the ContentType == 'Item' and that seems to have done the job. Now the formatting only shows up on list items and not on Folders.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

I think I figured out the solution. I added a condition to see if the ContentType == 'Item' and that seems to have done the job. Now the formatting only shows up on list items and not on Folders.

View solution in original post

PatUmaknow
Frequent Visitor

Hi,

The problem with this solution is that you have to show the ContentType column to the view in order to use it in your JSON code, which is not expected from your customer.

A similar approach is to use the ContentTypeId value (it's not a column and it's recognized in the JSON code) and compare it with the content-type id of what you want to show/hide.

For example, to hide a button for folder, use the following (in the Style section):

"visibility": "=if(((indexOf([$ContentTypeId],'0x0120')) == 0),'hidden', 'visible')"

Note: 0x0120 is the id of the folder content-type.

 

Hi Pat, would you know how to get the IDs for all content types, even those custom we create? If yes, would you mind to tell or point some link for such? Thanks in advance.

https://www.sharepointdiary.com/2012/05/sharepoint-2010-content-type-ids.html

 

Content TypeID
 System0x
 Item0×01
 Document0×0101
 Event0×0102
 Issue0×0103
 Announcement0×0104
 Link0×0105
 Contact0×0106
 Message0×0107
 Task0×0108
 Workflow History0×0109
 Post0×0110
 Comment0×0111
 East Asia Contact0×0116
 Folder0×0120



#Read more: https://www.sharepointdiary.com/2012/05/sharepoint-2010-content-type-ids.html#ixzz7HwJyBrTf

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,994)