How to: Trigger Transforms in the Module Editor

Overview

Once you create your transform, you'll trigger it in your application. When you trigger a transform in Unqork, you'll always start with a Plug-In component. But, the configuration for your Plug-In changes based on which editor you're in. You'll also configure your Plug-In for what you want the output of your transform to do. In this article, you'll learn the different ways you can trigger your transforms in the Module Editor. Here are a couple of ways you can trigger your transforms:

  • Execute with Input Data

  • Pre-Request Transform

What You'll Learn

In this article, you'll learn:

Triggering a Transform Using an Execute with Input Data

One way to trigger your transform is to select Execute Transform with Input Data from the Internal Services drop-down menu. You can use this service to reference any transform in any module in your environment. You can also specify which fields you want to transform in your submission data. To reference the transform and your fields, you'll enter the right inputs into your Plug-In. Then, using these inputs as the API call's request body your Plug-In executes your transform.

NOTE  In this article, we'll cover the basics of using an Execute with Input Data transform trigger. For more information, search Transforms Sidebar Option in our In-Product Help.

In the Plug-In Inputs table, you'll enter the following: 

  • The module ID of the module where you added the transform.
  • The name of the transform you want to trigger.
  • The name of the field(s) you want to transform.

Let's move on to your Plug-In Outputs table. You'll fill in the Outputs table based on your transform type. For an Input transform, you'll map the information coming out of the transform to fields in your module. This overrides the original information. For an Output transform, you'll map the information coming from the transform to where it'll go. This could be text, JSON data, or a PDF.

NOTE  Your Execute Transform with Input Data outputs your transformed data as an object.

So, you'll enter the component Property ID in the Property ID column of the Outputs table. Then, you'll enter the data type of your transform in the Mapping column. You'll write your mapping based on the following data types: 

Data Type Mapping
JSON data jsonData
Text txtData

PDF

pdfUrl

NOTE  You can also map your transform output to XML format. We'll cover mapping to XML in another lesson.

For example, say you use an Input transform that transfers data into JSON. You want to store that data in a Hidden component. So, you'd enter dataTransform for the component's Property ID. Here's how the Outputs table would look: 

Now that you know how to trigger your transforms using Execute with Input Data, let's move on to a different method.

Triggering a Transform Using a Pre-Request Transform

You can also trigger a transform in the Module Editor by selecting a transform from the Pre-Request Transform menu. To display the Pre-Request Transform menu, set your Plug-In Request Type to PATCH, POST, or PUT.

A Pre-Request Transform is the first in a 2-step process. First, the Pre-Request Transform step transforms your data. Then, it uses your transform output as the input for your Plug-In. That way, you’ll use the Pre-Request Transform to use your transformed data directly in an API call. To transform data with a Plug-In, you’ll use Execute Transform with Input Data as the trigger.

To set up a Pre-Request Transform trigger in your Plug-In, do the following: 

NOTE  These instructions assume you have a new module open, saved, and with a title. These instructions also assume you have added a Plug-In component to your Module Editor canvas.

1. Open the Plug-In component that you'll use to trigger your Pre-Request Transform.
2. Select which Service Type you'll use for your transform.
3. Select which Internal Service or External Service you'll use for your transform, if applicable. Your Pre-Request doesn't require you to select a service.
4. Select PATCH, POST, or PUT for the Request Type. Selecting one of these options causes the Pre-Request Transform drop-down menu to appear under Service Type.
5. Select your transform from the Pre-Request Transform drop-down menu.

NOTE  To select a transform, you must first create one in the Module Editor. For more information on how to create a transform, search for Transforms Sidebar Option in our In-Product Help.

When you use a Pre-Request Transform trigger, the API call’s request body won’t need the Plug-In’s Inputs table. Instead, the API call’s request body is the output of your executed transform. So, when using a Pre-Request Transform, leave the Inputs table empty. Note that Pre-Request Transform only uses transform parameters as your request body. Meaning that you can only select transforms saved to the module you’re in.

NOTE  As you just learned, the Pre-Request Transform uses your transform as the request body of your API call. That means your transform must include the input parameters to run as expected.