Conditionally Display Microsoft Flow Activating Buttons in Sharepoint Libraries Using Column Formatting
Before Column Formatting:
After Column Formatting:
Introduction
This post goes over how I used Sharepoint’s Column Formatting to solve some points of friction I experienced when executing a specific automated workflow. If you have not read my post on creating an automated file sharing workflow, you can read it here: blog post. This post is a continuation of sorts, but can also be a stand-alone read where you can learn how to use column formatting to solve some of your specific problems.
Column Formatting allows you to customize the look and feel of your Sharepoint library or list. Column Formatting lets you do whatever you want, as long as you follow it’s schema. People have used Column Formatting to make document lists visually meaningful and incorporating useful features such as buttons that simplify activating automated workflows. I will go over how I incorporated a flow activating button to solve some pain points I had in my automated flow.
Problem
Solution
You can copy the Schema below:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "button", "txtContent": "Create Link", "customRowAction": { "action": "executeFlow", "actionParams": "{\"id\": \"<ID_OF_FLOW_HERE>"}" }, "style": { "border": "none", "cursor": "pointer", "background-color": "#2980b9", "color": "#FFF", "padding": "4px 4px 4px 4px", "border-radius": "5px", "display": "=if(indexOf('[$FileLeafRef]', '.vsd') != -1, 'none', if(indexOf('[$FileLeafRef]', '.pro') != -1, 'none', if(indexOf('[$FileLeafRef]', '.msi') != -1, 'none', if(indexOf('[$FileLeafRef]', '.pcm') != -1, 'none', if(indexOf('[$FileLeafRef]', '.pcc') != -1, 'none', if(indexOf('[$FileLeafRef]', '.iso') != -1, 'none', if(indexOf('[$FileLeafRef]', '.cs') != -1, 'none', if(indexOf('[$FileLeafRef]', '.mac') != -1, 'none', if(indexOf('[$FileLeafRef]', '.prt') != -1, 'none', if(indexOf('[$FileLeafRef]', '.csv') != -1, 'none', if(indexOf('[$FileLeafRef]', '.xps') != -1, 'none', 'block')))))))))))", "visibility": "=if(((indexOf([$ContentTypeId],'0x0120')) == 0),'hidden', 'visible')" } }
Conclusion
Document libraries do not have to be boring. With Sharepoint Column Formatting, the applications are endless. From adding character and visual cues to libraries, to implementing buttons, column formatting is an easy tool to add into your workflow that can make document libraries or lists a little more fun and intuitive. In my case, I was able to implement a one click solution to reduce friction in our automated workflow by adding a flow activating button that renders only for supported files. This has greatly increased the user experience for the workflow by preventing wasted time trying to activate flows on unsupported files, only to get a failed flow. Thanks for reading!
For more information on column formatting, here is a link to some documentation from Microsoft: https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting