Get keyset from map
Function: Get Keys from a Collection
This action helps you extract all the unique labels (or "keys") from a collection of data. Imagine you have a list of items, and each item has a unique name or identifier associated with it. This action gathers all those names into a simple list.
For example, if you have a collection of customer records where each record is identified by a "Customer ID", this action will give you a list of all the "Customer IDs".
Input
- Map: This is the collection of labeled items you want to process. Each item in this collection has a unique label (key) and an associated value.
Output
- Result: A list containing all the unique labels (keys) that were found in your input collection.
Execution Flow
Real-Life Examples
Here are some ways you can use the "Get Keys from a Collection" action in your applications:
Example 1: Listing Product Identifiers
Imagine you have a collection of products in your inventory, where each product is stored with a unique Product ID as its label. You want to get a simple list of all these Product IDs.
- Inputs:
- Map: A collection representing your product inventory.
\{
"PROD-001": \{ "name": "Laptop", "price": 1200 \},
"PROD-002": \{ "name": "Mouse", "price": 25 \},
"PROD-003": \{ "name": "Keyboard", "price": 75 \}
\}
- Map: A collection representing your product inventory.
- Result: A list containing all the product identifiers.
[
"PROD-001",
"PROD-002",
"PROD-003"
]
Example 2: Identifying Submitted Form Fields
When a user submits a form, the data often comes as a collection where each form field has a name (like "firstName", "email") and the user's input as its value. You might want to get a list of all the fields that were part of the submission.
- Inputs:
- Map: A collection representing a submitted contact form.
\{
"firstName": "Alice",
"lastName": "Smith",
"email": "[email protected]",
"message": "Hello!"
\}
- Map: A collection representing a submitted contact form.
- Result: A list of all the field names from the form.
[
"firstName",
"lastName",
"email",
"message"
]
Example 3: Checking Available Configuration Options
Suppose your application stores various configuration settings as a collection, where each setting has a unique name (e.g., "theme", "language", "notifications"). You want to display a list of all available configuration options to an administrator.
- Inputs:
- Map: A collection of application settings.
\{
"theme": "dark",
"language": "en-US",
"notificationsEnabled": true,
"timezone": "UTC"
\}
- Map: A collection of application settings.
- Result: A list of all the configuration setting names.
[
"theme",
"language",
"notificationsEnabled",
"timezone"
]