Map to attribute
Function: Map to attribute
This function helps you transform a list of complex data records into a simpler list containing only a specific piece of information (an attribute) from each record. Imagine you have a list of customer profiles, and you only need a list of their email addresses. This function does exactly that, allowing you to easily extract a single type of data from a larger collection.
Input
- Array: (Type: List of Data) The original list of data records or objects you want to process. Each item in this list should be a data record with various fields. This input is required and cannot be empty.
- Attribute: (Type: Data Attribute) The specific field or piece of information you want to extract from each record in your input list. The available attributes will depend on the structure of the data in your "Array" input. This input is required.
Output
- The mapped array name: (Type: List of Variables) A new list containing only the values of the chosen attribute, extracted from each item in the original input list. This output list will hold the simplified collection of data.
Execution Flow
Real-Life Examples
Example 1: Extracting Product Names from an Inventory List
Scenario: You have a list of all products in your inventory, and you need a simple list of just their names to display in a dropdown menu.
Inputs:
- Array:
[ \{ "ID": "P001", "Name": "Laptop Pro", "Price": 1200, "Category": "Electronics" \}, \{ "ID": "P002", "Name": "Wireless Mouse", "Price": 25, "Category": "Accessories" \}, \{ "ID": "P003", "Name": "External Monitor", "Price": 300, "Category": "Electronics" \} ] - Attribute:
Name
Result: A new list named "The mapped array name" containing [ "Laptop Pro", "Wireless Mouse", "External Monitor" ].
Example 2: Getting a List of Customer Email Addresses
Scenario: You have a database of customer records and you want to send out a newsletter. You need a list of all customer email addresses.
Inputs:
- Array:
[ \{ "CustomerID": "C101", "Name": "Alice Smith", "Email": "[email protected]", "Phone": "555-1234" \}, \{ "CustomerID": "C102", "Name": "Bob Johnson", "Email": "[email protected]", "Phone": "555-5678" \}, \{ "CustomerID": "C103", "Name": "Charlie Brown", "Email": "[email protected]", "Phone": "555-9012" \} ] - Attribute:
Email
Result: A new list named "The mapped array name" containing [ "[email protected]", "[email protected]", "[email protected]" ].
Example 3: Listing Order Statuses for Review
Scenario: You have a list of recent customer orders and you want to quickly see the status of each order without all the other details.
Inputs:
- Array:
[ \{ "OrderID": "ORD001", "Customer": "Alice Smith", "Status": "Shipped", "Total": 1225.00 \}, \{ "OrderID": "ORD002", "Customer": "Bob Johnson", "Status": "Processing", "Total": 50.00 \}, \{ "OrderID": "ORD003", "Customer": "Charlie Brown", "Status": "Delivered", "Total": 315.00 \} ] - Attribute:
Status
Result: A new list named "The mapped array name" containing [ "Shipped", "Processing", "Delivered" ].