List Formatting Quick Tip: Format Only Columns

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:

LaunchFlowFormat

 

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!

  1. In your list view choose Add column then in the list of types choose More…
    AddAColumnMore
  2. Give the column a name and choose Calculated for the type. In the formula box enter =”” then click OK:
    EmptyCalculatedColumn
  3. 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!

FormatOnlyInformationPanel

4 thoughts on “List Formatting Quick Tip: Format Only Columns

  1. Hi Chris,

    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?

    • Thanks!

      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.

  2. Hi Chris,

    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.

    Many thanks,

    Geraint

    • 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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s