Ask AI
Skip to main content

Map to body

Function: Map to body

This action takes a list of structured items (like records from a database or an API response) and transforms it into a new, simplified list. Each item in the new list will primarily contain the main content (or "body") of the original item, along with any associated metadata such as ID, creation date, and modification details. This is useful for simplifying complex data structures or preparing data for display or further processing.

Input

  • List The original list of items you want to transform. Each item in this list is expected to have a main content section (its 'body') and might also include details like an ID, who created/modified it, and when. This input is required and cannot be empty.

Output

  • The mapped list name A new list containing the transformed items. Each item in this new list will be a simplified version of the original, primarily holding its main content ('body') and any relevant metadata that was present.

Execution Flow

Real-Life Examples

Example 1: Simplifying Product Data for a Web Page

Imagine you're building an e-commerce site and receive a complex list of product data from an external API. Each product item contains a lot of technical metadata, but you only need the core product details (name, price, description) and its unique ID for display.

  • Inputs:
    • List: [ \{ "id": "prod123", "status": "active", "body": \{ "name": "Laptop Pro", "price": 1200, "description": "High-performance laptop." \}, "createdBy": "admin", "creationDate": "2023-01-15T10:00:00Z" \}, \{ "id": "prod456", "status": "active", "body": \{ "name": "Wireless Mouse", "price": 25, "description": "Ergonomic design." \}, "createdBy": "admin", "creationDate": "2023-01-16T11:00:00Z" \} ]
  • Result: A new list named "Product Display Data" is created, containing simplified product objects: [ \{ "name": "Laptop Pro", "price": 1200, "description": "High-performance laptop.", "id": "prod123", "createdBy": "admin", "creationDate": "2023-01-15T10:00:00Z" \}, \{ "name": "Wireless Mouse", "price": 25, "description": "Ergonomic design.", "id": "prod456", "createdBy": "admin", "creationDate": "2023-01-16T11:00:00Z" \} ]. This list is now easier to use for populating your product display.

Example 2: Preparing Customer Records for a CRM System

You have a list of customer records from your internal database, which includes system-generated fields like internal IDs and audit trails. You need to send this data to an external CRM system that only accepts the core customer information and a unique customer ID.

  • Inputs:
    • List: [ \{ "internalId": "db_cust_001", "body": \{ "customerName": "Alice Smith", "email": "[email protected]", "phone": "555-1234" \}, "id": "CRM_CUST_A1", "creationDate": "2022-05-01T09:00:00Z" \}, \{ "internalId": "db_cust_002", "body": \{ "customerName": "Bob Johnson", "email": "[email protected]", "phone": "555-5678" \}, "id": "CRM_CUST_B2", "creationDate": "2022-06-10T14:00:00Z" \} ]
  • Result: A new list named "CRM Ready Customers" is created, containing customer data formatted for the CRM: [ \{ "customerName": "Alice Smith", "email": "[email protected]", "phone": "555-1234", "id": "CRM_CUST_A1", "creationDate": "2022-05-01T09:00:00Z" \}, \{ "customerName": "Bob Johnson", "email": "[email protected]", "phone": "555-5678", "id": "CRM_CUST_B2", "creationDate": "2022-06-10T14:00:00Z" \} ].

Example 3: Extracting Event Details from Log Entries

Your application generates detailed log entries, each containing a body with the actual event message and additional fields like the user who triggered it and the timestamp. You want to create a simpler list of just the event messages and timestamps for reporting.

  • Inputs:
    • List: [ \{ "logLevel": "INFO", "body": \{ "message": "User 'John' logged in successfully." \}, "id": "event_001", "createdBy": "system", "creationDate": "2023-10-26T08:30:00Z" \}, \{ "logLevel": "WARN", "body": \{ "message": "Failed attempt to access resource 'X'." \}, "id": "event_002", "createdBy": "system", "creationDate": "2023-10-26T08:35:15Z" \} ]
  • Result: A new list named "Simplified Events" is created, containing: [ \{ "message": "User 'John' logged in successfully.", "id": "event_001", "createdBy": "system", "creationDate": "2023-10-26T08:30:00Z" \}, \{ "message": "Failed attempt to access resource 'X'.", "id": "event_002", "createdBy": "system", "creationDate": "2023-10-26T08:35:15Z" \} ]. This list is now streamlined for quick review or further analysis.