Sometimes you want to create a column but you don’t care about it’s contents. I do this all the time when creating Flow buttons:
By providing a button directly in the list view that launches a flow for the given item you make it far easier for users to know about the availability of the flow, make it easy to quickly get their job done, and you can even provide additional context such as a tooltip or specific icon. You can see how to do this (and then just cut/paste/modify the format) using the Launch Flow for the Selected Item column formatting sample.
It’s a great sample and a great use case for column formatting. However, the quick tip I want to share with you is how to easily make a format only column. A format only column is part of your view but doesn’t get in the way while editing or creating items.
The values of Calculated columns can’t be retrieved in list formatting, but these columns can still have column formats associated with them. So the trick is to use an empty calculated column!
- In your list view choose Add column then in the list of types choose More…
- Give the column a name and choose Calculated for the type. In the formula box enter =”” then click OK:
- Now you can apply whatever format you want by using the column menu and choosing Column Settings > Format this column and pasting it in.
Now you have a column that can have a format applied to make your views look awesome, but won’t show up in the information panel!
See this demoed on the PnP Call (Live from MVP Summit):
Love List Formatting?
Join the Bi-weekly (every other Thursday) SharePoint Patterns and Practices special interest group for general development call where I will be presenting a new List Formatting Quick Tip on each call!
Also, come get the full picture in my sessions about List Formatting at the SharePoint Conference in Las Vegas in May, or the European Collaboration Summit in Germany in May:
- Use KENT to save $50 for the SharePoint Conference
- Register for the European Collaboration Summit
6 thoughts on “List Formatting Quick Tip: Format Only Columns”
Saw you in Charlotte! Great job!
I was just able to get your List formatter installed on a test basis so I’m excited to be able to apply it in the real world!
My question is – is there a way to use the “Mail to” and the “Current User” in the same column? It seems right now I can have one or the other.
Of course, the person who’s name is highlighted does not need to send themselves a note — but the person who is overseeing the project might want to send an e-mail to that person regarding the current line item.
Any thoughts on that?
I’m not sure I understand what you’re trying to do. You can use the @me to highlight fields/rows for the current user and still have a MailTo link generated. The current user will change based on whoever is logged in but the MailTo will have the email address of the person field. Feel free to provide more details and I’d be happy to help.
This is a great tip and to potentially extend it I was wondering if there is any way of scripting the creation of this column using the PNP Powershell Add-PnPField command?
I can’t seem to get it to work and keep getting a ‘Formula can’t be empty’ error.
Any help would be much appreciated.
This looks like it might be an issue with CSOM (the underlying API used by PnP PowerShell): https://github.com/SharePoint/PnP-PowerShell/issues/1488
Looking at the actual code seems to confirm that as well since the field is created then the formula is simply set and the field updated (no evaluation is done by the PowerShell code) so the empty error is coming from the server.
However, I found that using the Add-PnPFieldFromXml worked (despite getting a Cannot complete this action) error. Here’s the command I used:
Add-PnPFieldFromXml -List Test -FieldXml “<Field Type=’Calculated’ DisplayName=’Action’ Name=’Action’><Formula>=””””</Formula></Field>”
If you wanted to add your formatting you can just add another attribute called CustomFormatter.
[…] Today in SPDev weekly @theChrisKent gave a demo on view formatting, which describes how you can trigger a workflow from a list using View formatting. The details can be found here on his Blog […]
[…] a button with Column Formatting to launch a flow is a fantastic way to make actions obvious (not hidden in the Flow menu). If you have a list item […]