How to create a JSON sub-list with the Pluck card in Okta Workflows

In this guide:

  1. Okta Workflows guides
  2. Creating a sub-list with the Pluck card
  3. Testing the Pluck card
  4. Workflows resources

Okta Workflows guides

Okta Workflows guides are questions and answers from the community office hours, the #okta-workflows channel on MacAdmins Slack, and other places. Read all the other guides.

How do you create a JSON sub-list with the Pluck card in Okta Workflows?

This guide will teach how to use and test the List – Pluck card.

Creating a sub-list with the Pluck card

The List – Pluck card takes a list of objects and a key and produces a sub-list.

It does that by using the key to pluck the key values. These values become the sub-list.

Pluck card image
Pluck card

The following are several examples.

The input list is:

[
    {
        "product": "apple"
    },
    {
        "product": "tuna"
    },
    {
        "product": "bell peppers"
    },
    {
        "product": "milk"
    }
]

The key is product. After pluck, the resulting sub-list is:

["apple","tuna","bell peppers","milk"]

The following example uses a similar list:

[
    {
        "product": "apple",
        "type": "fruit"
    },
    {
        "product": "tuna",
        "type": "fish"
    },
    {
        "product": "bell peppers",
        "type": "vegetable"
    },
    {
        "product": "milk",
        "type": "dairy"
    }
]

The key is product. After pluck, the resulting sub-list is the same:

["apple","tuna","bell peppers","milk"]

The next example shows a more complex JSON list:

[
    {
        "properties": {
            "sheetId": 0,
            "title": "Sheet1",
            "index": 0,
            "sheetType": "GRID",
            "gridProperties": {
                "rowCount": 1000,
                "columnCount": 20
            }
        }
    },
    {
        "properties": {
            "sheetId": 317732887,
            "title": "Sheet2",
            "index": 1,
            "sheetType": "GRID",
            "gridProperties": {
                "rowCount": 1010,
                "columnCount": 15
            }
        }
    },
    {
        "properties": {
            "sheetId": 2125125274,
            "title": "Sheet3",
            "index": 2,
            "sheetType": "GRID",
            "gridProperties": {
                "rowCount": 1500,
                "columnCount": 22
            }
        }
    },
    {
        "properties": {
            "sheetId": 144976084,
            "title": "Sheet4",
            "index": 3,
            "sheetType": "GRID",
            "gridProperties": {
                "rowCount": 900,
                "columnCount": 10
            }
        }
    },
    {
        "properties": {
            "sheetId": 1179906118,
            "title": "Sheet5",
            "index": 4,
            "sheetType": "GRID",
            "gridProperties": {
                "rowCount": 1300,
                "columnCount": 8
            }
        }
    },
    {
        "properties": {
            "sheetId": 1615383701,
            "title": "Sheet6",
            "index": 5,
            "sheetType": "GRID",
            "gridProperties": {
                "rowCount": 2000,
                "columnCount": 30
            }
        }
    },
    {
        "properties": {
            "sheetId": 561243345,
            "title": "Sheet7",
            "index": 6,
            "sheetType": "GRID",
            "gridProperties": {
                "rowCount": 500,
                "columnCount": 5
            }
        }
    }
]

The key can be dot-delimited. Using the properties.gridProperties for key, the card creates the following list:

[
  {
    "rowCount": 1000,
    "columnCount": 20
  },
  {
    "rowCount": 1010,
    "columnCount": 15
  },
  {
    "rowCount": 1500,
    "columnCount": 22
  },
  {
    "rowCount": 900,
    "columnCount": 10
  },
  {
    "rowCount": 1300,
    "columnCount": 8
  },
  {
    "rowCount": 2000,
    "columnCount": 30
  },
  {
    "rowCount": 500,
    "columnCount": 5
  }
]

Testing the Pluck card

There are several options for testing the Pluck card.

The first option is to enter each list item directly when testing. Click the row and enter a list item:

Adding list items image
Adding list items

Testing the Pluck card with four items list:

Testing the Pluck card image
Testing the Pluck card

This approach works but can be time-consuming if the list is complex or extensive.

Test the entire flow for quick testing. Use the JSON – Parse card to create a JSON list and pass it to the Pluck card. Then, test the flow.

Pluck card in a flow image
Pluck card in a flow

Execution history shows the Pluck card result:

Testing the Pluck card as part of a flow image
Testing the Pluck card as part of a flow

Workflows resources

🍫 Get help from Workflows specialists during weekly community office hours.

πŸ“Ί Learn from Workflows videos.

πŸ›Ÿ Get help from support: discuss a Workflows topic or ask a question.

πŸ™‹πŸ»β€β™€οΈ Get help from the community: join the #okta-workflows channelon MacAdmins Slack.

Leave a comment