Forum Discussion
JSON view and column formatting
Robin Nilsson THANK YOU for your speedy and thorough response!
I totally agree with you about being able to reference a JSON file - I'm creating a JSON file and storing it in Site Assets to help document, but that takes manual updating in two places, which typically doesn't get handled. I'm also trying to create a single document that I can use as a reference, pulling together information from a number of sources that I figure will help me work faster, but ...
I was thinking since you and I both like the idea of referencing a file that one of us should create a UserVoice entry, and found that there actually is one, but it had only one vote, as did some other SharePoint UserVoice entries about JSON. Perhaps a better way to approach it is to create an entry that is more inclusive of various ideas? E.g. "Enhance view and column formatting" to be something like (more ideas would be wonderful):
Enhance view and column formatting
- Provide an out of the box facility via the web interface to allow users to make selections to modify the formatting rather than having to generate the JSON themselves.
- Allow the JSON to be specified with a file reference rather than having to put the code directly in a field. (See also user voice entry: Allow View Formatting to reference external file, https://sharepoint.uservoice.com/forums/329214-sites-and-collaboration/suggestions/35836723-allow-view-formatting-to-reference-external-file).
- Prompt for updating view formatting JSON when someone with appropriate rights changes the display width of a field.
- Allow the Name field for a document to be formatted via view formatting and improve the formatting capabilities via column formatting (some things can be done using @currentField)
- Allow comments in JSON used for formatting (or at least provide tools to limit VS Code to allow only what SharePoint JSON formatting allows)
- Display an indicator on the list or library Settings page for each column that has column formatting set.
- Provide JSON formatting controls to modify grouping display.
- lindabusdieckerOct 23, 2019Brass Contributor
Robin Nilsson As you suggested, it's now done!
If it helps with anything you write up to generate interest, this is what I sent to some folks in my sphere of influence:
Please help raise Microsoft’s awareness that we want SharePoint Online view and column formatting to be improved by voting for my https://sharepoint.uservoice.com/forums/329214-sites-and-collaboration/suggestions/38876674-enhance-view-and-column-formatting.
There some neat stuff that can be done using JSON, but it’s complicated and I haven’t run into a site owner or contributor yet who wants to learn how to write up the JSON.
In order to vote, you’re clicking on a Subscribe button that causes updates to be sent to you about the suggestion, but there’s a link at the bottom of every email message update that allows you to unsubscribe.
There are other people interested in this type of thing, but so far all the UserVoice suggestions are disjointed and haven’t gotten many votes, which you need in order to get Microsoft’s attention. (And … I thought it was pretty cool - I actually had someone from Oregon encourage me to post the idea.
)Thank you!
- theChrisKentOct 24, 2019MVP
lindabusdiecker These are some great ideas!
If you are looking for a way to manage files and deployment directly from VS Code, DavidWarner has put together some samples of ways to do this with either PowerShell or the O365CLI. You can find all of that here: (fair warning, that, while powerful, it's definitely much more in the realm of development. But if things get daunting, David or I would be happy to help): https://github.com/SharePoint/sp-dev-list-formatting/tree/master/tools/general-dynamic-deployment-with-vscode
Your suggestion of providing out of the box interfaces to generate the JSON is a great one and one that Microsoft is actively working on. You'll see it in action on certain column types (datetime, choice, yes/no and a few others) and it's called Design Mode: https://www.youtube.com/watch?v=0sR7peVBNPk&list=PLR9nK3mnD-OXgMjDBdjWUTRia89oixBhx&index=14&t=0s
These are somewhat simplistic now but much more is coming in the future. The team demoed it at SPC last May and it should be pretty awesome. Hoping to see more about that soon.
You can implement comments in your JSON file by simply adding an attribute and setting the value. It's not super intuitive and could be better but it can be far better than forgetting how something works later. Fortunately, these values are totally ignored by the formatting engine and so they don't cause any problems. Here's a simple example:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json", "elmType": "div", "txtContent": "Hey there!", "comment": "Totally useless format that just shows 'Hey there!', Wowee!" }The use of "comment" above is totally arbitrary (you can use whatever key you want).
I too would like to be able to reference a file for my formatting (similar to JS Link)! But in the meantime here are a couple of tips that I use:
- Site Columns can contain formats and this makes for a more centralized place to use them across your site collection. If a user changes the format on a list field you can simply update the site column and have it push down it's changes.
- PnP Provisioning templates fully support column and view formats. You can extract a template of your site and reapply at any time.
- Formats can be applied via PowerShell and the O365CLI (see above for examples) so writing centralized deployment scripts is fully possible
You can find other tips/demos here: https://www.youtube.com/playlist?list=PLR9nK3mnD-OXgMjDBdjWUTRia89oixBhx
- Robin NilssonOct 24, 2019Bronze Contributor
theChrisKent Thank you! Glad to hear the Design Mode will be expanded - that can take care of about of 30% of the customizations I've had to do in old SharePoint. And good tip about Site Columns - never thought of attacking the issue from that angle. Off to watch YouTube videos!
One of the reasons I'm not pushing harder for moving from On Premise to SPO is due to the little bits of formatting I've done to make life easier for folks - not critical enough to pull out PowerApps customizations but they would be missed. With updates to column/view formatting and the newly hinted at Form Customizations that could very well change...