0:00
/
0:00
Transcript

The Evolution of Custom Row Actions in List Formatting JSON

Custom row actions significantly enhance SharePoint lists, improving user interaction. Initially, these actions were simple links, but they have evolved into intelligent tools that adapt based on user activity. You can manage these actions effectively using column formatting. This evolution introduces new, highly useful features. You configure these actions through column formatting, which allows for the addition of conditional logic, making them exceptionally powerful. Column formatting is crucial for guiding users and is therefore very important. The underlying mechanism for defining these custom row actions and their conditional behaviors is through List Formatting JSON definitions.

Key Takeaways

  • Custom row actions make SharePoint lists better. They help users do things easily. You can add buttons and links to list items.

  • You can make actions smart. They can show or hide based on rules. They can also send different information. This makes your lists more helpful.

  • You can use actions to start Power Automate flows. You can also change column values. This helps you automate tasks and manage data quickly.

  • Actions help with document libraries. You can preview, copy, or move files. This makes handling documents easier.

  • Good practices make actions work well. Keep your code simple. Plan for your lists to grow. This makes your solutions last longer.

Basic Row Actions

You started with basic tools. These tools helped you make your list items interactive. They let you control how people use your data. This first set of tools prepared the way for more complex actions.

Simple Action Rules

To make a custom row action, use customRowAction. Put it inside a button. This tells SharePoint what to do. You pick an action with an action key. Use a text value. For example, use “action”: “defaultClick” to open an item. This simple rule connects actions to parts of your list. You can put these actions in buttons. You can also put them in spans or divs. This gives you many choices.

{
  “elmType”: “button”,
  “txtContent”: “Open this item”,
  “customRowAction”: {
    “action”: “defaultClick”
  }
}

Some actions need more information. For example, setValue needs an actionInput object. This object holds extra details. It includes field names and new values. When you use executeFlow, you give flow details. Use the actionParams attribute for the flow ID. These parts are key in your list formatting json.

Main Action Types

The first main actions were like SharePoint buttons. defaultClick opened an item. It worked like a double-click. editProps opened the edit form. share showed the share box. copyLink put the item’s link on your clipboard. comment opened the comments panel. It went right to the comments. delete let you remove an item. These actions were simple. But they became strong with conditional column formatting. You could show or hide them. This depended on your data. This made using the list better.

Two other strong actions are setValue and executeFlow. setValue changes column values. It does this without opening a form. You can even use formulas to update values. For example, you can add one to a number. executeFlow runs Power Automate flows. It runs them right from a list item. This was a big step. It let you start workflows with one click. You set up these actions in the column formatting pane.

Old Problems

These basic actions gave good control. But they had some limits. They mostly worked on one item at a time. You could not easily act on many items. This was true with custom column formatting. The dynamic features were also limited. You often needed complex rules. This was for different situations. These early versions led to today’s advanced features. The need for better solutions pushed column formatting forward.

Dynamic Actions and Conditional Logic

This part shows how custom row actions got smarter. You can make them intelligent now. They change based on your data. They also change based on what users need. This makes your SharePoint lists stronger. You use column formatting for this.

Conditional Display

You want actions to show only when needed. The display setting helps you. It lets you show or hide actions. This depends on certain rules. This is key for conditional formatting. You write an if statement. If the rule is true, the action shows. If false, it stays hidden.

For example, you may want an action. It is only for Word documents. You can check the file name.

“display”: “=if(indexOf([$FileLeafRef], ‘.docx’) > 0, ‘flex’, ‘none’)”

This code checks the file name. It looks for “.docx”. If found, the action appears. If not, it stays hidden. This uses indexOf on FileLeafRef. It checks for file types. This feature makes column formatting better. It guides users to the right actions. This is a main idea in conditional formatting.

Dynamic Parameters

Custom row actions can also send changing data. This makes them flexible. The actionParams setting helps here. You use actionParams with executeFlow. It sends details to a Power Automate flow. Remember, actionParams is an escaped JSON string. You must escape all double quotes inside it.

You give the flow’s ID. You can also change the flow panel’s look.

Here is how you set up executeFlow with actionParams:

{
  “$schema”: “https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json”,
  “elmType”: “button”,
  “customRowAction”: {
    “action”: “executeFlow”,
    “actionParams”: “{\”id\”:\”f7ecec0b-15c5-419f-8211-302a5d4e94f1\”, \”headerText\”:\”Do the things and stuff\”,\”runFlowButtonText\”:\”Lazerify!\”}”
  },
  “attributes”: {
    “class”: “ms-fontColor-themePrimary ms-fontColor-themeDark--hover”,
    “title”: “Launch Flow”
  },
  “style”: {
    “border”: “none”,
    “background-color”: “transparent”,
    “cursor”: “pointer”
  },
  “children”: [
    {
      “elmType”: “span”,
      “attributes”: {
        “iconName”: “Flow”,
        “class”: “ms-font-xxl”
      }
    }
  ]
}

This example shows a button. It starts a flow with an ID. It also sets a custom header. It sets custom button text. This control is strong for column formatting.

You also use actionInput for other actions. actionInput uses simpler JSON. You do not need to escape it. Actions like setValue and embed use actionInput. For setValue, give the column name. Give the new value. For embed, set height, width, and the link. This makes setting up these actions easy.

Beyond flows, you can make user interaction better. You do not need full custom forms. The openApprovalDialog action opens the SharePoint approval box. This is good if approvals are on your list. You can also use openContextMenu. This opens the item’s menu. It works like a right-click. These actions offer quick ways to use items. They work well with your column formatting.

Using Column Values

You can make custom row actions truly dynamic. You do this by using values from other columns. These columns are in the same row. This is a main part of column formatting. You get a column’s value using its internal name. Put the internal name in square brackets. Add a dollar sign before it. For example, [$InternalName]. This works because column formatting applies to the whole row. It lets you use all field values in that row.

This ability is key for conditional formatting. You can build dynamic links. You can update fields based on current data.

Column values can be referenced within SharePoint list formatting JSON to dynamically configure custom row actions. This is achieved by using the internal name of the field, enclosed in square brackets and preceded by a dollar sign, like [$InternalName]. This method works because the column is formatted within the context of the entire row, granting access to other field values within that row.

For instance, to create a dynamic hyperlink using a column value, you can embed “[$ID]” within the href property of an elmType: “a” element, as shown in the following example:

{
  “elmType”: “a”,
  “txtContent”: “”,
  “attributes”: {
    “target”: “_blank”,
    “iconName”: “OpenInNewWindow”,
    “class”: “sp-field-quickAction”,
    “href”: {
      “operator”: “+”,
      “operands”: [
        “http://intranet.maib.local/sites/help/Workflows/preluareElement/preluareElement.aspx?List={7a9edd38-3f18-4bef-99f6-062067196fa2}&ID=”,
        “[$ID]”,
        “&ItemGuid={690E069D-F5E7-45B3-9BED-123844A03316}&TemplateID={dbe5af40-944e-4a76-afa4-df336141cbf6}&Source=http%3A%2F%2Fintranet%2Emaib%2Elocal%2Fsites%2Fhelp%2FLists%2FCerere%2520de%2520suport%2FAllItems%2Easpx”,
        “@currentField”
      ]
    }
  }
}

This example makes a dynamic link. It uses the item’s ID ([$ID]). This builds a special URL. This shows how powerful referencing column values is. It helps you make interactive solutions. These solutions know their context. This is key for good column formatting. It makes your list formatting json definitions more useful. You can use this for conditional formatting rules. You can also fill parts of a json object.

Advanced Integrations

You can now use stronger actions. These actions connect things better. They go beyond simple tasks. You can link your lists to other services. You can also handle your documents better.

Triggering Power Automate Flows

You can start Power Automate flows. You can do this right from your list items. This is a strong feature. It makes hard tasks automatic. You use the executeFlow action. This action needs the flow’s special ID. You send this ID using actionParams. Remember, actionParams uses special JSON. You must change all double quotes inside its text.

To start a Power Automate flow from a custom row action in SharePoint list formatting, use this JSON code:

{
  “customRowAction”: {
    “action”: “executeFlow”,
    “actionParams”: “{\”id\”: \”[FLOW_IDENTIFIER]\”}”
  }
}

The action is set to executeFlow. The actionParams has a JSON text. It holds the id of the Power Automate flow. You should change [FLOW_IDENTIFIER] to your flow’s real ID. You can find this on the flow’s details page. Choose ‘Export’ then ‘Get flow identifier’.

This lets you start tasks with one click. You can also send live data from your list. This makes your automatic tasks smarter. You set up these actions in your column formatting. This gives you full control. You decide when and how users start flows.

External Data Interactions

You can put outside content. You can put it right into your list views. The embed action makes this happen. This action uses actionInput. You set the height, width, and the embed link. This link must be from an approved site. SharePoint has sites like YouTube already approved. You can add more sites in your settings.

For example, you can embed a YouTube video. Get the embed link from YouTube’s share option. Then set the height and width. Make them match the video’s size. This makes watching smooth. You can also create these links as you go. Use formulas to build the link. Base it on column values. This means each row can show different content. This makes your data look better. You can show media next to your list data.

The setValue action lets you change column values. You can change one or many columns at once. This action also uses actionInput. You give the column’s internal name. You also give the new value. You can use formulas for the new value. For example, you can add one to a number. You can also change many columns in one action. This is very strong for quick data changes.

Think about setValue versus “quick steps.” setValue works on one item. It changes specific columns. It does this right from your column formatting. “Quick steps” let you pick many items. You can then do a set action. Both ways are fast. setValue gives you exact control per item. “Quick steps” let you update many things.

Complex Action Scenarios

Document libraries have special actions. These actions make file handling easy. The previewFileAction opens a file preview. This is good for a quick look. It does not open the file’s program. This gives a steady preview. This is not like clicking the file directly.

The copyFile action lets you copy a file. You copy it to a chosen place. The moveFile action moves a file. It takes the file from its spot. It puts it in a new spot. Both actions use actionParams. You set the destinationUrl in this special JSON. You can make this URL change. You can build it with formulas. This means you can copy or move files. You can do this based on their state. You can also move them to certain folders. This makes sure files go to the right place. It stops user mistakes.

These actions are like “quick steps.” You can set up “quick steps” to copy or move files. This lets users pick many files. They can then copy or move them. You can check how “quick steps” are set up. Use tools like SP Editor. This tool shows list details. It shows the JSON code for quick steps. This helps you learn their structure. This helps you make your own actions. These actions can be more dynamic.

You can also make hard tasks. You can do this with existing actions. For example, show an ‘Edit’ button.

This gives a direct way to edit an item. It skips the usual click. This is one way to mix actions. You can make special user experiences. These make your data look better. They guide users through tasks. All these strong connections are possible. They use flexible column formatting.

Practical Applications

You can use custom row actions in many ways. These actions make your SharePoint lists stronger. They help users do tasks. You can put many actions together. This makes a custom toolbar. It makes things easy to use. You also help users with special workflows. You show actions only when needed. This uses column formatting well.

Workflow Automation

Custom row actions make approvals faster. They also give quick updates. You can work with items right in the list. This makes workflows simpler. For example, make ‘Approve’ and ‘Reject’ buttons. These buttons use the setValue action. They change fields like ‘ItemStatus’. They also change ‘ApprovalActionBy’. You do not need to open other forms. This makes approvals quicker.

Custom row actions help with approvals. They use column formatting in SharePoint. You can work right in the list. The JSON code shows ‘Approve’ and ‘Reject’ buttons. When clicked, they use setValue. This updates ‘ItemStatus’ and ‘ApprovalActionBy’. You do not need to go to other pages. This makes approvals faster and easier.

{
  “$schema”: “https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json”,
  “elmType”: “div”,
  “style”: {
    “flex-directon”: “row”,
    “justify-content”: “left”,
    “align-items”: “center”,
    “flex-wrap”: “nowrap”
  },
  “children”: [
    {
      “elmType”: “div”,
      “style”: {
        “display”: “=if([$ItemStatus] == ‘Pending’ || [$ItemStatus] == ‘’, ‘inherit’,’none’)”,
        “flex-directon”: “row”,
        “justify-content”: “left”,
        “align-items”: “center”,
        “flex-wrap”: “wrap”
      },
      “children”: [
        {
          “elmType”: “button”,
          “customRowAction”: {
            “action”: “setValue”,
            “actionInput”: {
              “ItemStatus”: “Approved”,
              “ApprovalActionBy”: “@me”
            }
          },
          “attributes”: {
            “class”: “ms-fontColor-themePrimary ms-fontColor-themeDarker--hover”
          },
          “style”: {
            “border”: “none”,
            “background-color”: “transparent”,
            “cursor”: “pointer”,
            “display”: “flex”,
            “flex-directon”: “row”,
            “justify-content”: “left”,
            “align-items”: “center”,
            “flex-wrap”: “wrap”
          },
          “children”: [
            {
              “elmType”: “span”,
              “attributes”: {
                “iconName”: “SkypeCircleCheck”
              },
              “style”: {
                “padding”: “4px”
              }
            },
            {
              “elmType”: “span”,
              “txtContent”: “Approve”,
              “style”: {
                “word-break”: “keep-all”
              }
            }
          ]
        },
        {
          “elmType”: “button”,
          “customRowAction”: {
            “action”: “setValue”,
            “actionInput”: {
              “ItemStatus”: “Rejected”,
              “ApprovalActionBy”: “@me”
            }
          },
          “attributes”: {
            “class”: “ms-fontColor-themePrimary ms-fontColor-themeDarker--hover”
          },
          “style”: {
            “border”: “none”,
            “background-color”: “transparent”,
            “cursor”: “pointer”,
            “display”: “flex”,
            “flex-directon”: “row”,
            “justify-content”: “left”,
            “align-items”: “center”,
            “flex-wrap”: “wrap”
          },
          “children”: [
            {
              “elmType”: “span”,
              “attributes”: {
                “iconName”: “Blocked”
              },
              “style”: {
                “padding”: “4px”
              }
            },
            {
              “elmType”: “span”,
              “txtContent”: “Reject”,
              “style”: {
                “word-break”: “keep-all”
              }
            }
          ]
        }
      ]
    },
    {
      “elmType”: “div”,
      “children”: [
        {
          “elmType”: “span”,
          “txtContent”: “=’This item is ‘ + toLowerCase([$ItemStatus])”,
          “style”: {
            “display”: “=if([$ItemStatus] == ‘Pending’ ||[$ItemStatus] == ‘’ , ‘none’,’inherit’)”,
            “padding-left”: “5px”,
            “word-break”: “keep-all”
          }
        }
      ]
    }
  ]
}

Enhanced Data Management

You can use custom row actions. They help manage data better. This includes quick updates. It also helps with changing many items. These actions make lists more active. They also show data better. You can do common tasks. Do them right from the list. This is possible with column formatting.

  • defaultClick: This opens an item. It is like clicking a title.

  • share: This opens a sharing box. You can share the item.

  • delete: This opens a pop-up. You can delete the item.

  • editProps: This opens the item’s edit window.

  • executeFlow: This runs a Microsoft Flow. It connects to the item.

These actions and column formatting give you control. They help you manage data well.

Custom Navigation

You can make custom ways to move around. Do this in your lists. Custom row actions make this happen. You can add links to menus. You can also add to the toolbar. This helps users move through content. This is a good use of column formatting.

  • Add custom links to the menu. Use EditControlBlock actions. Set Location=”EditControlBlock”. Add a Url for moving around.

  • Extend the toolbar in modern lists. Use CommandUI.Ribbon actions. Set Location=”CommandUI.Ribbon”. Set CommandAction with a URL. This lets you move from toolbar items.

These ways let you build custom navigation. They make data look better. They also make users interact more.

Best Practices and Future

Performance and Maintainability

You should make custom row actions work well. Make your JSON easy to read. Keep your column formatting simple. Do not use very hard expressions. Use clear names for your parts. This helps others get your code. Write down how your solutions work. Explain why you made choices. This makes your column formatting easier to fix. It also keeps it working for a long time. Think about adding notes in your JSON. This makes hard parts clear. You can also split big formats. Make them into smaller, easy parts. This makes things clearer. You can find many examples. Look in the List Formatting repo. These examples show good ways to work. They help you learn good column formatting skills.

Scalability Considerations

Think about how your column formatting will get bigger. Small JSON files work better. Try your column formatting on big lists. Make sure your expressions work fast. Do not do extra math. This stops slow loading. Your list formatting json definitions should work with many items. Plan for more things later. Hard formats can make pages load slowly. Always think about users first. Keep your JSON short. Think about how many items are in your list. Very big lists might need simpler formats.

Future Developments

Expect more actions in column formatting. Microsoft always adds new things. Look for better links with other services. Maybe more ways to change data will come. The list formatting json will keep changing. Always check the formatting pane. Look for new choices there. This keeps you current on what it can do. The List Formatting repo is a good place. You can find many examples there. It shows what you can do now. It also hints at what is coming. These new things will make your lists stronger. You can build more active solutions. Think about even easier ways for users to work.

You have learned about custom row actions. They started simple. Now they are powerful tools. These tools help you get more done. They make your SharePoint lists active. Use these new features. Make smart and strong solutions. More new things will come. Your lists will get even better.

FAQ

What are custom row actions in SharePoint?

Custom row actions add buttons. They add links to list items. You use JSON for these actions. This is in column formatting. They help you control users. They help users use your data. Your lists become more active. They become easier to use.

How do you make custom row actions dynamic?

You make actions dynamic. You use special rules. The display setting hides or shows actions. This depends on rules. You also use actionParams. This is for complex data. Flow IDs are an example. actionInput handles simpler data. This is for setValue or embed.

Can you use custom row actions in document libraries?

Yes, you can use them. You can use them in document libraries. Actions like previewFileAction show files. copyFile and moveFile help with documents. You set destination URLs. These URLs can change.

What is the difference between actionParams and actionInput?

actionParams needs special JSON. You must change all double quotes. This is for actions like executeFlow. actionInput uses simpler JSON. You do not need to change quotes. Actions like setValue and embed use actionInput.

Discussion about this video

User's avatar

Ready for more?