Ask AI
Skip to main content

Map form to object

Function: Map form to object

This action helps you organize data collected from a form into a structured object. Imagine you have a form where users enter various pieces of information. Instead of dealing with each form field separately, this action lets you define how these fields should be grouped and named within a single, easy-to-use object. This is especially useful when you want to save form data to a database record, send it to another system, or process it further as a single unit.

Input

  • Mapping body: This is where you define the rules for how your form data should be transformed. You specify which form fields (by their unique identifier or name) correspond to which properties in your new object, and how they should be structured (e.g., simple fields, nested groups, or lists of items). This input is required.

Output

  • Result: This is the name of the variable where the newly created object, containing your mapped form data, will be stored. By default, this variable is named CREATED_DATA.

Execution Flow

Real-Life Examples

Let's consider a scenario where you have a "New Customer Registration" form.

Example 1: Simple Customer Profile

You have a form with fields for Customer Name, Email Address, and Phone Number. You want to combine these into a CustomerProfile object.

  • Inputs:
    • Mapping body:
      \{
      "name": "Customer Name",
      "email": "Email Address",
      "phone": "Phone Number"
      \}
      (Here, "Customer Name", "Email Address", and "Phone Number" refer to the unique identifiers or names of your form fields.)
    • Result: CustomerProfile
  • Result: A new variable named CustomerProfile will be created, containing an object like this:
    \{
    "name": "Alice Smith",
    "email": "[email protected]",
    "phone": "555-123-4567"
    \}

Example 2: Customer Profile with Nested Address

Building on Example 1, you also have form fields for Street, City, State, and Zip Code. You want to nest these address details within the CustomerProfile object.

  • Inputs:
    • Mapping body:
      \{
      "name": "Customer Name",
      "email": "Email Address",
      "address": \{
      "street": "Street",
      "city": "City",
      "state": "State",
      "zipCode": "Zip Code"
      \}
      \}
      (The nested structure for "address" tells the platform to create a sub-object for these fields.)
    • Result: CustomerProfile
  • Result: A new variable named CustomerProfile will be created, containing an object like this:
    \{
    "name": "Bob Johnson",
    "email": "[email protected]",
    "address": \{
    "street": "123 Main St",
    "city": "Anytown",
    "state": "CA",
    "zipCode": "90210"
    \}
    \}

Example 3: Order with Multiple Line Items

Imagine an order form where a customer can add multiple products. The form has a "Product List" section (a repeating group of fields) where each entry has fields for Product Name, Quantity, and Price. You want to map these into an order object with a list of items.

  • Inputs:
    • Mapping body:
      \{
      "orderId": "Order ID Field",
      "customerEmail": "Customer Email Field",
      "items": \{
      "productName": "Product Name Field",
      "quantity": "Quantity Field",
      "price": "Price Field"
      \}
      \}
      Note: In the "Mapping body", when you define a key (like "items") with a nested object, it tells the platform to look for a form section that allows multiple entries (a "group" or "repeating section") and apply the nested mapping rules to each entry within that section, resulting in a list of objects.
    • Result: CustomerOrder
  • Result: A new variable named CustomerOrder will be created, containing an object like this:
    \{
    "orderId": "ORD-2023-001",
    "customerEmail": "[email protected]",
    "items": [
    \{
    "productName": "Laptop",
    "quantity": 1,
    "price": 1200.00
    \},
    \{
    "productName": "Mouse",
    "quantity": 2,
    "price": 25.00
    \}
    ]
    \}