Skip to main content

How to Setup Lookups

Updated this week

What Are Lookups and Why Are They Important?

Lookups in GelatoConnect serve as translation tables that convert data from your system into formats that Gelato can understand. They're essential for seamless API integration, particularly for mapping:

  • Product IDs/SKUs: Convert your custom product identifiers to Gelato's standardized product UIDs

  • Shipping Methods: Map your shipping method names to Gelato's carrier codes

  • Carrier Identifiers: Translate carrier names between systems

  • Other Custom Mappings: Any value that needs consistent translation between systems

Without lookups, orders might fail when your system's identifiers don't match Gelato's expected values. Lookups provide a reliable way to bridge this gap, ensuring consistent order processing.

Key Benefits of Using Lookups

βœ… Lookups ensure data is standardized for Gelato's system. Preventing mismatches between customer-specific and Gelato-compatible values.
βœ… They allow fallback values to avoid errors in case of missing mappings.
βœ… Bulk CSV uploads make it easier to manage large-scale mappings.

Setting Up Lookups: Step-by-Step Guide

1. Access the Lookups Page

  1. Log in to your GelatoConnect account

  2. Navigate to Workflow > Order Intake in the left-hand menu

  3. Click on Lookups to view existing mappings or create new ones

2. Create a New Lookup Table

Option A: Manual Creation

  1. Click the Create button at the top of the page.

  2. Enter a descriptive Name for your lookup (e.g., "Product SKU Mapping")

  3. Select the Customer this lookup will apply to from the dropdown.

  4. Add a Description (optional but recommended) to help identify the lookup's purpose.

  5. Enter a Template Field - this is the reference used in template mapper code to access this lookup.

  6. Enter a Template Field - this is the reference used in template mapper code to access this lookup. The lookup template field must be surrounded by double curly braces (e.g., {{sku}}).

  7. Add mappings by clicking the + icon:

    • Key: Enter the value from your system (e.g., your product SKU or code).

    • Value: Enter the corresponding Gelato value (e.g., Gelato's product UID).

  8. Repeat for all values that need mapping.

  9. Click Save Changes to apply the configuration.

Option B: Bulk Import (Recommended for Many Values)

  1. Prepare an Excel or CSV file with two columns:

    • Column A: Header "Lookup key" followed by your system's values

    • Column B: Header "Product UID" followed by Gelato's corresponding values

  2. Click Create to start a new lookup

  3. Fill in the Name, Customer, Description, and Template Field as above

  4. Click Import instead of manually adding entries

  5. Select your prepared Excel/CSV file

  6. Review the imported mappings

  7. Click Save Changes to complete the setup

Video Guide

3. Implement Lookups in Your Template Mapper

After setting up your lookup tables, you need to reference them in your template mapper code (using Jinja2):

  1. Go to Workflow > Order Intake > Templates

  2. Edit the template where you want to use lookups

  3. In the Template Mapper section, use the lookups() function to access your mapping tables

  4. Basic syntax: {{ lookups({"alias": value_to_lookup}, strict=False, default="fallback_value")|js }}

Example 1: Product UID Mapping

{% set productUid = lookups({"sku": item.sku}, strict=False, default=item.sku) %}
"productUid": {{ productUid|js }},

Example 2: Shipping Method Mapping

"shipmentMethodUid": {{ lookups({"shipping_code": order.shipping.method}, strict=False, default="normal")|js }},

The strict=False parameter ensures the code won't error if a match isn't found, and the default parameter provides a fallback value.

Testing Your Lookups

Always test your lookups before using them in production:

  1. Go to your template in the Templates section

  2. Navigate to the Template Testing tab

  3. Use the test form to verify that your lookups are correctly translating values

  4. Check that missing keys correctly use your default value

  5. Submit a test order and verify the order is processed as expected

Common Use Cases

Product SKU to Gelato UID Mapping

Map your internal product codes to Gelato's product UIDs:

{% set productUid = lookups({"sku": item.sku}, strict=False, default=item.sku) %}
"productUid": {{ productUid|js }},

Shipping Method Translation

Convert your shipping method names to Gelato's shipment method UIDs:

{% set shipMethod = lookups({"shipping_method": order.shipping_type}, strict=False, default="normal") %} "shipmentMethodUid": {{ shipMethod|js }},

Carrier Mapping

Map carrier identifiers between systems:

{% set carrier = lookups({"carrier_code": shipment.carrier}, strict=False, default=shipment.carrier) %} "carrier": {{ carrier|js }},

Country-Specific State Code Mapping

Handle special cases for state codes in specific countries:

{% set stateCode = shipTo.state %}
{% if shipTo.country|upper == "US" %}
{% set stateCode = lookups({"us_state": shipTo.state}, strict=False, default=shipTo.state) %}
{% endif %}
"state": {{ stateCode|js }},

Troubleshooting Lookups

If your lookups aren't working as expected:

  • Check for exact matches: Keys are case-sensitive and must match exactly with what's in your API data

  • Verify template field names: Ensure the template field in your lookup matches what's referenced in your template

  • Use strict=False: This prevents errors when a lookup key is missing

  • Always provide defaults: Set appropriate default values to handle missing mappings

  • Check the full request payload: Use the Requests page to examine the payload that's being processed

Best Practices

  • Use descriptive naming: Name lookups clearly to indicate their purpose

  • Add descriptions: Include details about when and where each lookup is used

  • Keep mappings up to date: Regularly review and update lookups as products or services change

  • Use bulk import for large datasets: Save time by importing lookups in bulk

  • Test thoroughly: Always test lookups with both matching and non-matching values

  • Document your lookups: Maintain records of which lookups are used in which templates

Next Steps

Now that you've set up lookups for your API integration, you might want to:

  1. Learn about creating a template for order Intake

  2. Set up postbacks to update your customers

Need more help? Contact our support team at [email protected]

Did this answer your question?