SharePoint Online modern list view customization using JSON Example (Add button for current user)

In this SharePoint customization tutorial, we will discuss how to add a custom button in each row of the list in the SharePoint modern list view using JSON. In this SharePoint Online modern list view customization example using JSON, we will add a custom button “Please give your comments”.

As we know in the year 2016, the SharePoint Online team released Modern List and Library experience in both SharePoint On-Premise and SharePoint Online. So now a day business recommends this feature for more benefits.

Here I am not using ant JSLink to customize our modern list rather than, I am going forward to use JSON for an excellent user interface.

If we go in detail, there are many good features added in both modern lists and libraries but here I am using those called List View Customization.

SharePoint Online modern list view customization example

Now, we will see an example on how to add a custom button in rows for the current user in SharePoint Online modern list view using JSON.

Step 1: I have created a SharePoint Online List called Feedback List and it contains following column name.

  • Title – Single Line Text
  • Comments – Single Line Text
  • Assigned To – People and Group
image 200

Step 2: Next click on All Items and click on Format View to implement our customization code.

SharePoint Online modern list view customization

Step 3: Next copy the below code and paste it inside code editor and click on Save.

{
  "schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
  "hideSelection": true,
  "hideColumnHeader": true,
  "rowFormatter": {
    "elmType": "div",
	"style": {
      "display": "flex",
      "flex-wrap": "wrap",
      "align-items": "stretch",
      "padding": "8px",
      "margin-bottom": "25px",
      "max-width": "420px",
      "border-radius": "8px",
      "box-shadow": "4px 4px 8px lightblue"
    },
    "attributes": {
      "class": "sp-row-card ms-bgColor-themePrimary ms-fontColor-white"
    },
    "children": [
      {
        "elmType": "div",
        "style": {
          "text-align": "left"
        },
        "children": [
          {
            "elmType": "div",
            "attributes": {
              "class": "sp-row-title"
            },
            "txtContent": "[$Title]"
          },
          {
            "elmType": "div",
            "attributes": {
              "class": "sp-row-listPadding"
            },
            "txtContent": "[$Comments]"
          },
          {
            "elmType": "button",
            "customRowAction": {
              "action": "defaultClick"
            },
            "txtContent": "Please give your Comments",
            "attributes": {
              "class": "sp-row-button"
            },
            "style": {
              "display": {
                "operator": "?",
                "operands": [
                  {
                    "operator": "==",
                    "operands": [
                      "@me",
                      "[$AssignedTo.email]"
                    ]
                  },
                  "",
                  "none"
                ]
              }
            }
          }
        ]
      }
    ]
  }
}

Step 4: Once I click on the Save button, My SharePoint Online List view got changed to different views which same as the below screenshot.

SharePoint Online modern list view customization example

Step 5: Once you click on custom button, It will redirect you to view page where you can edit your item.

SharePoint Online modern list view customization using JSON

This is all about customization of List View in SharePoint Modern List.

Reference: for ms-bgcolor change, you can follow the below URL

In this SharePoint Online modern list view customization using JSON Example, we discussed how to add a custom button in rows for current user in SharePoint Online modern list view using JSON.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

>