Required Fields

Handling vendor-required custom fields when placing orders

Some pricing options require additional information from the buyer before an order can be placed. These vendor-defined custom fields capture data like serial numbers, equipment models, or service details that the vendor needs to fulfill the order.


Custom Field Properties

Each custom field in the /catalog/detail response has these properties:

Property
Type
Description

fieldId

string

Unique identifier—use this in the order request

prompt

string

User-facing label for the field

description

string

Additional context or instructions

isRequired

boolean

Whether the field must be provided

formatRegex

string

Validation pattern (if any)

errorMessage

string

Message to show if validation fails

placeholder

string

Example value for the input field

Example Response

{
  "options": [
    {
      "priceOptionId": "OPT-ABC123",
      "price": 850.00,
      "condition": "Aftermarket",
      "customFields": [
        {
          "fieldId": "serial_number",
          "prompt": "Equipment Serial Number",
          "description": "The serial number of the equipment this part will be installed on",
          "isRequired": true,
          "formatRegex": "^[A-Z0-9]{8,12}$",
          "errorMessage": "Must be 8-12 alphanumeric characters",
          "placeholder": "e.g., ABC12345XYZ"
        },
        {
          "fieldId": "purchase_order",
          "prompt": "Internal PO Reference",
          "description": "Your internal purchase order number for tracking",
          "isRequired": false,
          "formatRegex": null,
          "errorMessage": null,
          "placeholder": null
        }
      ]
    }
  ]
}

Submitting Required Fields

When creating an order, include the field values in requiredFields for each quote item:

Property
Type
Description

fieldId

string

Must match the fieldId from catalog detail

value

string

The user-provided value


Validation

Client-Side Validation

Always validate user input before submitting:

Server-Side Validation

The API validates required fields on order submission. Missing or invalid fields return 422 Unprocessable Entity:


Common Field Types

While vendors can define any custom fields, these are commonly seen:

Field Type
Typical fieldId
Purpose

Serial Number

serial_number, equipment_serial

Equipment identification for compatibility

Model Number

model_number, equipment_model

Equipment model for part matching

Asset Tag

asset_tag, asset_id

Internal asset tracking

PO Reference

po_number, purchase_order

Customer purchase order tracking

Cost Center

cost_center, department

Internal accounting allocation

Technician

technician_name, service_tech

Who will install the part


Handling Optional Fields

Not all custom fields are required. Check isRequired before enforcing validation:


UI Considerations

Displaying Custom Fields

Empty customFields Array

Many pricing options have no custom fields. Always check the array before rendering:


Error Handling

Error
Cause
Solution

422 Unprocessable Entity

Missing required field

Check isRequired fields have values

422 Unprocessable Entity

Invalid format

Validate against formatRegex before submitting

400 Bad Request

Unknown fieldId

Use exact fieldId from catalog detail

400 Bad Request

Wrong priceOptionId

Ensure fields match the selected option

Retry After Validation Error


Best Practices

  1. Fetch fresh catalog detail before displaying custom fields—they can change

  2. Validate client-side first to provide immediate feedback

  3. Preserve user input if server validation fails so users don't re-enter everything

  4. Display field descriptions to help users understand what's needed

  5. Use placeholder text as examples when available

  6. Handle empty arrays gracefully—not all options have custom fields

  7. Match fieldId exactly including case sensitivity


Last updated