SharePoint Modern List Form JSON Formatting

SharePoint's Modern List Form has significantly enhanced the user experience by introducing JSON formatting. This feature allows you to customize the appearance and behavior of your lists without writing any code. By leveraging JSON, you can create visually appealing and intuitive forms that cater to your specific business needs.

SharePoint List JSON Form Formatting & Validations (3)
SharePoint List JSON Form Formatting & Validations (3)

JSON formatting in SharePoint Modern List Form provides a flexible and powerful way to control the look and feel of your lists. It enables you to apply styles, rearrange fields, and even hide or show columns based on specific conditions. In this article, we will delve into the world of JSON formatting, exploring its capabilities and providing practical examples to help you unlock its full potential.

Display SharePoint List Items in a SPFX Web Part [Tabular Format]
Display SharePoint List Items in a SPFX Web Part [Tabular Format]

Understanding JSON Formatting in SharePoint Modern List Form

JSON (JavaScript Object Notation) is a lightweight data interchange format that is easy for humans to read and write and easy for machines to parse and generate. In the context of SharePoint, JSON formatting is used to apply styles and customize the presentation of list items.

How to customize Forms in SharePoint Lists 📃
How to customize Forms in SharePoint Lists 📃

JSON formatting in SharePoint Modern List Form uses a set of predefined properties and functions to manipulate the appearance of list items. These properties and functions are organized into a JSON object, which is then applied to the list view. By understanding the structure and syntax of JSON, you can create sophisticated and dynamic list views that engage users and improve productivity.

JSON Formatting Syntax Basics

Customizing SharePoint List Forms in InfoPath 2010
Customizing SharePoint List Forms in InfoPath 2010

Before we dive into the specifics of JSON formatting in SharePoint, let's quickly review the basic syntax of JSON. JSON is written in key-value pairs, enclosed in curly braces ({}). Each key is followed by a colon (:), and the value can be a string, number, object, array, boolean, or null.

Here's a simple example of JSON syntax: ```json { "name": "John Doe", "age": 30, "isEmployee": true, "hobbies": ["reading", "hiking", "movies"] } ``` In SharePoint JSON formatting, you'll use this basic syntax to define the styles and properties of your list items.

SharePoint JSON Formatting Properties and Functions

Add Conditional Formatting to a SharePoint Online List
Add Conditional Formatting to a SharePoint Online List

SharePoint provides a wide range of properties and functions that you can use in your JSON formatting. These properties and functions allow you to control the appearance of list items, including fonts, colors, spacing, and more. Some of the most commonly used properties and functions include:

  • fontWeight: Sets the font weight (boldness) of the text.
  • color: Sets the text color.
  • backgroundColor: Sets the background color of an element.
  • padding: Adds space between an element and its content.
  • margin: Adds space between an element and its neighboring elements.
  • iconName: Sets an icon to display next to the text.
  • iconColor: Sets the color of the icon.
  • showColumn and hideColumn: Shows or hides a specific column based on conditions.

You can find a comprehensive list of SharePoint JSON formatting properties and functions in the official Microsoft documentation: JSON formatting overview.

Customize SharePoint Forms with JSON
Customize SharePoint Forms with JSON

Applying JSON Formatting to SharePoint Modern List Form

Now that we have a solid understanding of JSON formatting and its capabilities, let's explore how to apply JSON formatting to your SharePoint Modern List Form.

How to List Unique Permissions for Files and Folders on a SharePoint Site
How to List Unique Permissions for Files and Folders on a SharePoint Site
SharePoint Page Section Templates Explained
SharePoint Page Section Templates Explained
Learn How To Implement Sharepoint List Validation
Learn How To Implement Sharepoint List Validation
How to implement Document Management System in SharePoint using Content Types | SharePoint Maven
How to implement Document Management System in SharePoint using Content Types | SharePoint Maven
How to Personalize SharePoint for Users
How to Personalize SharePoint for Users
Editing a Form: InfoPath
Editing a Form: InfoPath
SharePoint Content Types - BoostSolutions
SharePoint Content Types - BoostSolutions
Why You Should Never Embed Document Libraries and Lists into SharePoint Pages
Why You Should Never Embed Document Libraries and Lists into SharePoint Pages
Site Collections, Sites, Pages, Document Libraries, and Folders - putting it all together | SharePoint Maven
Site Collections, Sites, Pages, Document Libraries, and Folders - putting it all together | SharePoint Maven
Store and Reuse Document Templates in SharePoint
Store and Reuse Document Templates in SharePoint
How to track documents in SharePoint using Document ID feature | SharePoint Maven
How to track documents in SharePoint using Document ID feature | SharePoint Maven
The knowledge base Sharepoint intranet homepage
The knowledge base Sharepoint intranet homepage
How to Make Any SharePoint Page the New Homepage
How to Make Any SharePoint Page the New Homepage
Design Better SharePoint Pages | Content Pane Overview
Design Better SharePoint Pages | Content Pane Overview
SharePoint design examples - Content Formula
SharePoint design examples - Content Formula
an image of a web page with many different things on the screen and in the background
an image of a web page with many different things on the screen and in the background
two screens showing different types of information in the same language, and one with an arrow pointing
two screens showing different types of information in the same language, and one with an arrow pointing
6 Reasons Why You Need to Embrace SharePoint Content Types
6 Reasons Why You Need to Embrace SharePoint Content Types
the shareholders agreement is shown in this document, which includes two separate sections and one section
the shareholders agreement is shown in this document, which includes two separate sections and one section
SharePoint architecture: Benefits of a flat structure
SharePoint architecture: Benefits of a flat structure

To apply JSON formatting to a list view, follow these steps:

  1. Navigate to the list view where you want to apply the formatting.
  2. Click on the Format current view button in the command bar.
  3. Select JSON from the formatting options.
  4. Enter your JSON code in the provided editor.
  5. Click OK to apply the formatting.

You can also apply JSON formatting to a specific column by editing the column's properties and adding the JSON code in the JSON Formatting section.

Formatting a Column with JSON

Let's create a simple JSON formatting example that changes the font color and adds an icon to a column based on its value. In this example, we'll format the "Status" column to display a green checkmark icon for "Completed" items and a red exclamation point for "In Progress" items.

Here's the JSON code to achieve this: ```json { "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "span", "style": { "color": "=if([$Status] == 'Completed', '#3D9970', '#FF0000')" }, "attributes": { "iconName": "=if([$Status] == 'Completed', 'CheckMark', 'ErrorTriangle')", "iconColor": "=if([$Status] == 'Completed', '#3D9970', '#FF0000')" } } ``` In this example, we're using the if function to check the value of the "Status" column. If the value is "Completed", the text color and icon color are set to green, and a checkmark icon is displayed. If the value is "In Progress", the text color and icon color are set to red, and an exclamation point icon is displayed.

Conditional Formatting with JSON

JSON formatting also allows you to apply conditional formatting to your list views. Conditional formatting enables you to change the appearance of list items based on specific conditions, such as the value of a column or the result of a calculation.

Here's an example of conditional formatting that changes the background color of a row based on the value of the "Priority" column: ```json { "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json", "elmType": "div", "style": { "background-color": "=if([$Priority] == 'High', '#FFC1C1', if([$Priority] == 'Medium', '#FFFFC1', '#C1FFC1'))" } } ``` In this example, we're using nested if statements to check the value of the "Priority" column. If the value is "High", the background color of the row is set to light red. If the value is "Medium", the background color is set to light yellow. If the value is "Low", the background color is set to light green.

JSON formatting in SharePoint Modern List Form opens up a world of possibilities for customizing the appearance and behavior of your lists. By leveraging the power of JSON, you can create engaging and intuitive list views that enhance the user experience and improve productivity. So go ahead, experiment with JSON formatting, and unlock the full potential of your SharePoint lists!