Search code examples
jsonsharepointcascadingdropdownsharepoint-list

JSON Formatting on SharePoint List column to enable cascading dropdown


Been working on some sample code to format a list column B based on value of list column A.

I have 2 lists: List A - This list are the main list for data entry. Columns are Item, Region and Country. List B - This list contains 2 columns; Region and Country.

What I want to do is, based on user selection, only display Country corresponding to the selection Region. All Countries/Regions are maintained in List B.

So far I've tried:

{
  "$schema": "https://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
  "elmType": "div",
  "style": {
    "display": "inline-block",
    "padding": "10px 0 10px 0",
    "min-height": "auto"
  },
  "children": [
    {
      "elmType": "span",
      "style": {
        "display": "inline-block",
        "padding": "0 10px 0 0"
      },
      "attributes": {
        "iconName": "Folder"
      }
    },
    {
      "elmType": "a",
      "txtContent": "Show Countries",
      "attributes": {
        "target": "_top",
        "href": {
          "operator": "+",
          "operands": [
            "https://xxxxxxxxxxxx/AllItems.aspx?ID=",
            "@currentField.lookupValue",
            "[$Title]",
            "&FilterType1=Lookup"
          ]
        }
      }
    }
  ]
}

This obviously is not the correct solution, but being very new to JSON this is the best I could do by referencing msdn docs. The link works properly, although it's not needed for the final solution. Basically, I only want the user to see Country based on Region selection. I'm therefore missing the result as to display the lookup value rather than "Show countries".

Any help or pointers towards further help/documentation are greatly appriciated.


Solution

  • According to my research, the JSON formatting does not support create cascading dropdown on SharePoint Online.

    You can use SP service (JS) to create cascading drop-down list.

    Reference: