Add Custom Row Actions In SharePoint List Items With Column Formatting

In this article, you will learn how to add custom row actions in SharePoint list items with column formatting.

In this article, we will see how to use column formatting options to create action buttons in the SharePoint list view for each row. This can be used to customize SharePoint list view and provide options to perform an action on click. This can be achieved using customRowAction attribute in for button element. Before getting into an example, below are 5 actions available which can be used.
  • defaultClick - This will simulate item click event (when list item column like the title is clicked)
  • share - Opens a sharing dialog
  • delete - Opens a delete dialog confirmation popup
  • editProps - Opens item properties windows in edit mode
  • executeFlow - run MS flow associated based in Flow id (to be configured in JSON, we will see this in the example below)
First, let us start by creating a list. Add below columns for demo
  • Title (default)
  • Default Action - Calculated column with formula =""
  • Share Action - Calculated column with formula =""
  • Delete Action - Calculated column with formula =""
  • Edit Action - Calculated column with formula =""
  • Call Flow - Calculated column with formula =""
As we don't want these columns to be added in List add/edit form, we will create this as a calculated column with an empty string.
 
Below is an example of the column 'Default Action':
 
Add Custom Row actions in SharePoint list items with Column Formatting
 
Once you create all the columns, the list would look something like this.
 
Add Custom Row actions in SharePoint list items with Column Formatting

Default Action 

 
To apply column formatting to this column, we have 2 options:
 
Option 1
 
Go to List settings, select targeted column settings. In column settings, we will find Column formatting option at the end.
 
Add Custom Row actions in SharePoint list items with Column Formatting 
Option 2
 
Inside list view, select header arrow in the targeted column and follow the below steps.
 
Add Custom Row actions in SharePoint list items with Column Formatting
Add Custom Row actions in SharePoint list items with Column Formatting
 
Add this JSON for default action. 
  1. {  
  2.   "$schema""https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",  
  3.   "elmType""button",  
  4.   "customRowAction": {  
  5.     "action""defaultClick"  
  6.   },  
  7.   "attributes": {  
  8.     "class""ms-fontColor-themePrimary ms-fontColor-themeDark--hover",  
  9.     "title""Open Item"  
  10.   },  
  11.   "style": {  
  12.     "border""none",  
  13.     "background-color""transparent",  
  14.     "cursor""pointer"  
  15.   },  
  16.   "children": [  
  17.     {  
  18.       "elmType""span",  
  19.       "attributes": {  
  20.         "iconName""OpenPane",  
  21.         "class""ms-font-xxl"  
  22.       }  
  23.     }  
  24.   ]  
  25. }  
Open list view again and we should see the below output.
 
Add Custom Row actions in SharePoint list items with Column Formatting
 

Share action 

 
Edit column and add the below JSON for Share action.
  1. {  
  2.   "$schema""https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",  
  3.   "elmType""button",  
  4.   "customRowAction": {  
  5.     "action""share"  
  6.   },  
  7.   "attributes": {  
  8.     "class""ms-fontColor-themePrimary ms-fontColor-themeDark--hover",  
  9.     "title""Share Item"  
  10.   },  
  11.   "style": {  
  12.     "border""none",  
  13.     "background-color""transparent",  
  14.     "cursor""pointer"  
  15.   },  
  16.   "children": [  
  17.     {  
  18.       "elmType""span",  
  19.       "attributes": {  
  20.         "iconName""Share",  
  21.         "class""ms-font-xxl"  
  22.       }  
  23.     }  
  24.   ]  
  25. }  
Output
 
Add Custom Row actions in SharePoint list items with Column Formatting
 
Add Custom Row actions in SharePoint list items with Column Formatting
 

Delete action

 
Edit column and add the below JSON for Delete action, delete button will be added like arrow marked in the screenshot and on click of it, the confirmation dialog will open.
  1. {  
  2.   "$schema""https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",  
  3.   "elmType""button",  
  4.   "customRowAction": {  
  5.     "action""delete"  
  6.   },  
  7.   "attributes": {  
  8.     "class""ms-fontColor-themePrimary ms-fontColor-themeDark--hover",  
  9.     "title""Delete Item"  
  10.   },  
  11.   "style": {  
  12.     "border""none",  
  13.     "background-color""transparent",  
  14.     "cursor""pointer"  
  15.   },  
  16.   "children": [  
  17.     {  
  18.       "elmType""span",  
  19.       "attributes": {  
  20.         "iconName""Delete",  
  21.         "class""ms-font-xxl"  
  22.       }  
  23.     }  
  24.   ]  
  25. }  
Output
Add Custom Row actions in SharePoint list items with Column Formatting

Edit action 

 
Edit column and add the below JSON for Edit action. This will open the edit form.
  1. {  
  2.   "$schema""https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",  
  3.   "elmType""button",  
  4.   "customRowAction": {  
  5.     "action""editProps"  
  6.   },  
  7.   "attributes": {  
  8.     "class""ms-fontColor-themePrimary ms-fontColor-themeDark--hover",  
  9.     "title""Edit Item"  
  10.   },  
  11.   "style": {  
  12.     "border""none",  
  13.     "background-color""transparent",  
  14.     "cursor""pointer"  
  15.   },  
  16.   "children": [  
  17.     {  
  18.       "elmType""span",  
  19.       "attributes": {  
  20.         "iconName""Edit",  
  21.         "class""ms-font-xxl" 
  22.       }  
  23.     }  
  24.   ]  
  25. }  
output
 
Add Custom Row actions in SharePoint list items with Column Formatting

Call flow 

 
Edit column and add below JSON for Call flow action, this will open Start MS flow dialog.
 
To obtain a Flow's ID,
  1. Click Flow > See your flows in the SharePoint list where the Flow is configured
  2. Click on the Flow you want to run
  3. Copy the ID from the end of the URL
Please note here you need to replace actionParams id attribute with your actual MS Flow id. 
  1. {  
  2.   "$schema""https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",  
  3.   "elmType""button",  
  4.   "customRowAction": {  
  5.     "action""executeFlow",  
  6.     "actionParams""{\"id\":\"2cabd779-a135-420a-90f8-461d56e83fd0\", \"headerText\":\"It's Flow Time!\",\"runFlowButtonText\":\"Do it\"}"  
  7.   },  
  8.   "attributes": {  
  9.     "class""ms-fontColor-themePrimary ms-fontColor-themeDark--hover",  
  10.     "title""Launch Flow"  
  11.   },  
  12.   "style": {  
  13.     "border""none",  
  14.     "background-color""transparent",  
  15.     "cursor""pointer"  
  16.   },  
  17.   "children": [  
  18.     {  
  19.       "elmType""span",  
  20.       "attributes": {  
  21.         "iconName""Flow",  
  22.         "class""ms-font-xxl"  
  23.       }  
  24.     }  
  25.   ]  
  26. }  
output
 
Add Custom Row actions in SharePoint list items with Column Formatting
 
That's it, this is how we can create custom row actions buttons and add to SharePoint list view. This is an easy way to add button in SharePoint list view rather than using field customizer or creating custom list views to provide row actions to automate any business process.
 
This article is inspired from here.
 
Thanks to @thechriskent for the sample and demo in the community call of April 18, 2019.