Customize the list form using JSON in SharePoint Online step by step

Customize the list form using JSON in SharePoint Online step by step

No comments

 26,684 total views,  52 views today

In this article, we will learn about how to customize the list form using JSON in SharePoint Online step by step. Earlier, days in classic SharePoint we used to customize the SharePoint list form using the InfoPath Form designer, back then in SharePoint Online we have started actually using the PowerApps tool to customize the list form which works well, in fact, this current trend in the SharePoint Online /Office 365  work domain. In both, the tool is fast to customize the list form. In the long run, Microsoft always wanted to empower their customer in terms of using SharePoint Online as a content management system – so, keeping the user more productive in mind, Microsoft recently launched a new product as part of their regular roadmap plan where user can customize the list form using the JSON – which is very faster than other approaches (of course there are many limitations in this JSON way customizing, and it is not right to compare this JSON approach with the PowerApps ), with just a few clicks we can develop a nice looking form.

In the traditional approaches, the SharePoint list form looks flat where the columns are shown in order one after another where we cannot add the header, footer, and grouping the body of the form. Using the JSON format we can add header and footer in the list form and we can group the columns in many sections the way we want – exactly how we used to do in InfoPath and PowerApps.

Key-Highlights: What you will learn from this article?

  • How to configure the SharePoint list form layout?
  • How to add a header in the SharePoint list form using the JSON formatting?
  • How to add a footer in the SharePoint list form using the JSON formatting?
  • How to customize the SharePoint list form body using the JSON formatting?
  • How to configure the list form in SharePoint online?
  • How to add header and footer in SharePoint online?
  • How to create various sections in SharePoint online list form using JSON formatting?

In this demo, I will show how to customize the list form in SharePoint Online where I will add a header, footer to the form and group the columns in various sections.

Below is the screenshot of the box item edit form in modern SharePoint Online.

Open modern SharePoint Online list edit Form
Open modern SharePoint Online list edit Form

Now we will learn how to customize the SharePoint Online list form using the JSON formatting step by step.

Step by step process to customize the SharePoint list form using the JSON formatting

I assume you have a SharePoint custom list with few columns to it and at least an item.

Select and double click on the title link of the item, then from the right-side panel top corner, we could see a dropdown option that has below three  options:

  • Edit columns
  • Configure layout
  • Customize with PowerApps

The above dropdown list is used to configure the SharePoint list form.

Configure layout in SharePoint Online list form
Configure layout in SharePoint Online list form

Click on the “Configure Layout” option.

In the next, we will land on the “Format” screen.

There we could see a dropdown list “Apply formatting to” with the below values:

  • Header
  • Body
  • Footer

And, beneath that, we can see a big box for JSON formatting code.

Apply JSON formatting to SharePoint Online list form
Apply JSON formatting to SharePoint Online list form

Now, we will learn how to apply formatting in Header, Body, and Footer using JSON one by one.

How to apply JSON formatting in SharePoint online list form header?

Now let us see what happens when we select “Header” in the Apply formatting to the dropdown list.

The message says “Change the display of this form header by adding JSON below. Remove the text from the box to clear the custom formatting.”

Add the below JSON text to the box:

{
"debugMode": true,
"elmType": "div",
"attributes": {
"class": "ms-borderColor-neutralTertiary"
},
"style": {
"width": "99%",
"border-top-width": "0px",
"border-bottom-width": "1px",
"border-left-width": "0px",
"border-right-width": "0px",
"border-style": "solid",
"margin-bottom": "16px"
},
"children": [
{
"elmType": "div",
"style": {
"display": "flex",
"box-sizing": "border-box",
"align-items": "center"
},
"children": [
{
"elmType": "div",
"attributes": {
"iconName": "Group",
"class": "ms-fontSize-42 ms-fontWeight-regular ms-fontColor-themePrimary",
"title": "Details"
},
"style": {
"flex": "none",
"padding": "0px",
"padding-left": "0px",
"height": "36px"
}
}
]
},
{
"elmType": "div",
"attributes": {
"class": "ms-fontColor-neutralSecondary ms-fontWeight-bold ms-fontSize-24"
},
"style": {
"box-sizing": "border-box",
"width": "100%",
"text-align": "left",
"padding": "21px 12px",
"overflow": "hidden"
},
"children": [
{
"elmType": "div",
"txtContent": "='Details for ' + [$Title]"
}
]
}
]
}

Then click on the preview button.

Using JSON add header to the SharePoint Online list form
Using JSON add header to the SharePoint Online list form

Then we can see the header at the top of the form “Details for Smith”. Here the “Title” column is mapped for the header (“txtContent”) which displays the Title of the list item in the header.

 "txtContent": "='Details for ' + [$Title]"

Then, finally, if you are OK with the header look and feel, click on the “Save” button.

Now, we will learn how to apply the footer to the SharePoint Online list form.

How to apply JSON formatting in SharePoint online list form footer?

Similarly, we need to select the “Footer” from the “Apply Formatting To” dropdown selection.

Now let us see what happens when we select “Footer” in the Apply formatting to the dropdown list.

The message says “Change the display of this form footer by adding JSON below. Remove the text from the box to clear the custom formatting.”

Add the below JSON text to the box:

{
"debugMode": true,
"elmType": "div",
"style": {
"width": "100%",
"text-align": "left",
"overflow": "hidden",
"border-top-width": "1px"
},
"children": [
{
"elmType": "div",
"style": {
"width": "100%",
"padding-top": "10px",
"height": "24px"
},
"children": [
{
"elmType": "a",
"txtContent": "='Details for ' + [$Title]",
"attributes": {
"target": "_blank",
"class": "ms-fontColor-themePrimary ms-borderColor-themePrimary ms-fontWeight-semibold ms-fontSize-m ms-fontColor-neutralSecondary–hover ms-bgColor-themeLight–hover"
}
}
]
}
]
}

Now Click on the preview button, we can see that a footer a added to the form.

Using JSON add footer to the SharePoint Online list form
Using JSON add footer to the SharePoint Online list form

If you are ok with the footer text and format, you can click on the Save button.

Finally, we will learn how to customize the form body using the JSON in SharePoint Online.

How to apply JSON formatting in SharePoint online list form body?

Similar to the header and footer, now you need to select the “Body” from the “Apply Formatting To” dropdown selection.

Now let us see what happens when we select “Body” in the Apply formatting to the dropdown list.

The message says “Change the display of this form body by adding JSON below. Remove the text from the box to clear the custom formatting.”

Add the below JSON text to the box:

{
"debugMode": true,
"elmType": "div",
"attributes": {
"class": "ms-borderColor-neutralTertiary"
},
"style": {
"width": "99%",
"border-top-width": "0px",
"border-bottom-width": "1px",
"border-left-width": "0px",
"border-right-width": "0px",
"border-style": "solid",
"margin-bottom": "16px"
},
"children": [
{
"elmType": "div",
"style": {
"display": "flex",
"box-sizing": "border-box",
"align-items": "center"
},
"children": [
{
"elmType": "div",
"attributes": {
"iconName": "Group",
"class": "ms-fontSize-42 ms-fontWeight-regular ms-fontColor-themePrimary",
"title": "Details"
},
"style": {
"flex": "none",
"padding": "0px",
"padding-left": "0px",
"height": "36px"
}
}
]
},
{
"elmType": "div",
"attributes": {
"class": "ms-fontColor-neutralSecondary ms-fontWeight-bold ms-fontSize-24"
},
"style": {
"box-sizing": "border-box",
"width": "100%",
"text-align": "left",
"padding": "21px 12px",
"overflow": "hidden"
},
"children": [
{
"elmType": "div",
"txtContent": "='Details for ' + [$Title]"
}
]
}
]
}

Once we add the above JSON code to the box and click on the preview button, we will see that the form body has been customized with the various sections like “Employee General Information”, “Employee Basic Information”, and “Other Section”.

Using JSON add section and customize the SharePoint Online list form
Using JSON add the section and customize the SharePoint Online list form

Finally, if you are ok with the body formatting of the form, you can click on the “Save” button.

Format to customize the SharePoint list form:

Below is the sample JSON format to customize the list form.

{
"sections": [
{
//give a display name for the section
"displayname": "",
"fields": [
//reference your fields here using their display name
"Title"
]
},
{
//give a display name for the section
"displayname": "",
"fields": [
//reference your fields here using their display name
]
}
]
}

Below is the complete customize screen with the custom header, body, and footer.

Configure and Format SharePoint Online list form using JSON coding
Configure and Format SharePoint Online list form using JSON coding

Summary: What we had here?

Thus in this article, we have learned the below with respect to configuring and formatting the SharePoint Online list form using JSON:

  • How to configure the SharePoint list form layout?
  • How to add a header in the SharePoint list form using the JSON formatting?
  • How to add a footer in the SharePoint list form using the JSON formatting?
  • How to customize the SharePoint list form body using the JSON formatting?
  • How to configure the list form in SharePoint online?
  • How to add header and footer in SharePoint online?
  • How to create various sections in SharePoint online list form using JSON formatting?

See Also:

You may also like the below SharePoint article:

 

test