Product documentation
Patchworks services
Patchworks services
  • Services documentation
  • Getting started
    • What is a service?
  • Roles & Permissions
    • Roles & permissions summary (services)
  • Working with Services
    • Accessing services
    • The services list
    • The anatomy of a service
      • Service summary
      • Service canvas
      • Service filters
      • Service trigger
      • Service source
      • Service destination
      • Service mapping
      • Service alerts
      • Payload script
      • Run service
      • Service settings
    • Adding a Patchworks service
      • Add a default service
      • Configure service settings
      • Set the service trigger schedule
      • Define service filters
      • Define field mappings
      • Activate the service
    • Cloning an existing service
    • Updating a service
      • Service notes
      • Using a payload-level custom script in services
    • Removing a service
    • Field mappings & transformations (services)
      • Field mappings (services)
        • Mapping metafields for products (services)
      • Field transformations (services)
        • Transform function reference (services)
        • Using a custom script in field transformations (services)
      • Transform mapping/lookup tables (services)
      • Legacy shipment & payment maps (services)
  • Service connectors
    • What is a service connector?
    • Accessing service connectors
    • The anatomy of a service connector
    • Adding a service connector
    • Updating a service connector
    • Removing a service connector
  • Reporting & logging
    • Service sync reports
      • Viewing the service sync report
      • Handling failed service syncs
      • Sync failure email notifications
    • Service sync logs
    • Viewing logs for custom script activity in services
  • Service systems
    • Service systems
    • Supported service systems
      • Active Ants (service connector)
        • Finding service connector credentials for Active Ants
      • BigCommerce (service connector)
        • Finding service connector credentials for BigCommerce
        • Additional setup notes for BigCommerce (services)
      • Bleckmann (service connector)
        • Finding service connector credentials for Bleckmann (API)
      • Bleckmann Returns (service connector)
        • Finding service connector credentials for Bleckmann (Returns)
      • Bleckmann SFTP (service connector)
        • Finding service connector credentials for Bleckmann (SFTP)
      • Brightpearl (service connector)
        • Finding service connector credentials for Brightpearl
        • Additional setup notes for Brightpearl (services)
      • Business Central (service connector)
        • Finding service connector credentials for Business Central
      • Citrus-Lime (service connector)
        • Finding service connector credentials for Citrus-Lime
      • CommerceTools (service connector)
        • Finding service connector credentials for CommerceTools
      • Cybertill (service connector)
        • Finding service connector credentials for Cybertill
      • Descartes Peoplevox (service connector)
        • Finding service connector credentials for Peoplevox
        • Configuring Peoplevox as a data destination (services)
        • Quick setup CSV files for Peoplevox (services)
      • Dynamics NAV (service connector)
        • Finding service connector credentials for Dynamics NAV
      • Emarsys (service connector)
        • Finding service connector credentials for Emarsys (FTP)
      • EposNow (service connector)
        • Finding service connector credentials for EposNow
      • Global-e (service connector)
        • Finding service connector credentials for Global-e
      • Inventory Planner (service connector)
        • Finding service connector credentials for Inventory Planner
      • Khaos Control (service connector)
        • Finding service connector credentials for Khaos Control
      • Lightspeed Retail R-Series (service connector)
        • Authorising Patchworks to access your Lightspeed Retail R-Series account (services)
      • Lightspeed Retail X-Series (service connector)
      • Linnworks (service connector)
        • Finding service connector credentials for Linnworks
      • Magento 2 (service connector)
        • Finding service connector credentials for Magento 2
        • Required settings for Magento 2.4.4+ (services)
      • Mirakl (service connector)
        • Finding service connector credentials for Mirakl
      • Navision (service connector)
      • NetSuite (service connector)
        • Authorising Patchworks to access your NetSuite account (services)
        • Required NetSuite features (services)
        • Working with NetSuite custom fields (services)
        • Setting unique IDs for NetSuite product syncs (services)
        • NetSuite concurrency (services)
        • Troubleshooting NetSuite connections (services)
        • Additional setup notes for NetSuite (services)
        • Legacy service connector setup for NetSuite
          • Installing the Patchworks bundle for NetSuite (services)
          • Finding connector credentials for NetSuite (services)
      • Odoo (service connector)
        • Finding service connector credentials for Odoo
      • Ometria (service connector)
        • Finding service connector credentials for Ometria
      • Patchworks SFTP (service connector)
        • Finding basic auth service connector credentials for SFTP
        • Finding ssh auth service connector credentials for SFTP
        • Specifying a non-root folder as the file location (services)
        • Adding entity schemas (services)
      • Plytix (service connector)
        • Finding service connector credentials for Plytix
      • Prima (service connector)
        • Finding service connector credentials for Prima
      • ReBound (service connector)
        • Finding service connector credentials for ReBound
      • SAP Business One (service connector)
        • Finding service connector credentials for SAP Business One
      • Seko (service connector)
        • Finding service connector credentials for Seko (API)
        • Finding service connector credentials for Seko (FTP)
      • Shopify / Shopify+ (service connector)
        • Finding service connector credentials for Shopify (token auth)
        • Finding service connector credentials for Shopify (legacy auth)
        • Additional setup notes for Shopify (service connector)
      • Sitoo (service connector)
        • Finding service connector credentials for Sitoo
      • SparkLayer (service connector)
        • Finding service connector credentials for SparkLayer
      • The Edge by John Lewis (service connector)
        • Finding service connector credentials for The Edge by John Lewis
      • TikTok Shop (service connector)
        • Finding service connector credentials for TikTok Shop
      • Torque (service connector)
        • Finding service connector credentials for Torque
      • Veeqo
        • Finding service connector credentials for Veeqo
      • Vend (service connector)
        • Finding service connector credentials for Vend
      • Visualsoft (service connector)
        • Finding service connector credentials for Visualsoft
      • Voyado (service connector)
        • Finding service connector credentials for Voyado
      • WooCommerce (service connector)
        • Finding service connector credentials for WooCommerce
      • ZigZag (service connector)
        • Finding service connector credentials for ZigZag
  • Troubleshooting
    • How to manage failed service syncs
    • How to run a service manually
    • How to deactivate/activate a service
    • How to check the operational status of a service connector
    • What to check if you can't save a new service connector
    • How to handle an empty mapping page
    • What to do if your third-party systems go offline
  • Inbound API
    • Inbound API for services
    • Using the Inbound API connector with Patchworks services
      • Adding an inbound API connector with a custom payload
      • Generating token credentials for API access
      • Adding a Patchworks service for an inbound API connector
        • Add a default service
        • Configure service settings
        • Set the service trigger schedule
        • Define field mappings
        • Activate the service
      • Implementing API requests
  • Support
    • Raising a support ticket
Powered by GitBook
On this page
  • Introduction
  • The steps
  1. Working with Services
  2. Field mappings & transformations (services)
  3. Field transformations (services)

Using a custom script in field transformations (services)

PreviousTransform function reference (services)NextTransform mapping/lookup tables (services)

Introduction

This page explains how to apply a custom script as a transform function for service field mappings.

If this is the first time you are using this script, you are strongly advised to work with a test service and ensure everything syncs as expected before applying to live services.

In Patchworks, a test service can be created by defining test (rather than live) source and destination connectors which point to sandbox URLs for the associated systems.

The steps

Step 1 Access the :

Step 2 Click on the service that you wish to update:

Step 3 Click the mapping tab:

...existing field mappings are displayed:

Step 4 Click the mapping entry that you wish to update with a new transform (or add a new mapping row):

Step 5 Click the edit option associated with the expanded mapping entry:

Step 6 Click the add transformation button:

...the transformation editor is displayed, with a visual representation of the source and destination points for the mapping, together with an add new function option to define the required transformation between these two points:

A maximum of 15 custom scripts can be added to a single transform.

Step 7 Click the add new function option:

...function settings are displayed:

Step 8 Click in the function name field and select run custom script from the dropdown list:

The run custom script option is available for all data types except float.

...the transformation editor page updates and a new select custom script field is displayed:

Step 9 Click in the select custom script field to show a list of all available custom scripts, then choose the required entry for this mapping:

...the transformation editor page updates so the code and any variable fields for the selected script are shown:

...scroll down to view the code associated with this script:

Click the manage custom script link in the info box (see 1 above) to open the custom script in edit mode, in a new browser tab. There, you can make changes and save the script - then return to the transformation editor and click the refresh icon (see 2 above) to refresh the code.

Step 10 Update variable fields as required. Click in a variable field and choose either custom value (then enter a static value to the right):

...or select source mapping field (then select the required source mapping field to the right):

Step 11 Click the save function button:

...the transformation editor updates and your new function is displayed in the visual representation. From here, you can choose to add another function, or save transformation:

...you are returned to the mapping page, which now shows a transformation for the row you've been working on:

Step 12 Repeat these steps as required for any other mapping entries.

Please see if you're not sure how to get to this point.

You can't change custom script code here in the transformation editor. However, options are available so you can make changes to the original custom script, quickly and easily:

accessing services
services list