Why can’t I load sample data into my From Translator component?

Introduction

Nothing is wrong this is the correct behaviour!

The reason is simple: A From Translator component retrieves data by using Lua code to read data from disk, or another source — it does not listen for incoming messages like other components.

Tip: For the same reason you cannot resubmit messages to a From Translator.

Issue [top]

Why can’t I load sample data into my From Translator component?

Solution [top]

If you need to create sample/test data for a From Translator component you can to create a data file (or a dummy web service etc) that the From Translator component can use as input.

Alternatively you could even (temporarily) hard code test data within your channel that mimics the input you would receive. You can use iguana.isTest() to ensure that the test data is only used in the the Editor (test mode). If you take this approach we recommend putting the data in a local test module which can easily be modified or removed (rather than inline which is much less clean and tidy).

If you have any questions please contact us at support@interfaceware.com.

How it Works [top]

Once again remember that nothing is wrong, this is the correct behavior, though it can seem odd to new users.

The reason is simple enough: A From Translator component can only use Lua code to grab data (from disk, or a web service etc). Because of this a From Translator component will never receive data (sample or live) in the Data parameter to the main() function.

The Translator simply mimics how this component runs in a live situation by not passing sample data to it.

Tip: For the same reason you cannot resubmit messages to a From Translator.

Clear as mud? Well lets approach it from the other direction.

There are three From components that support sample data for their scripts:

  • LLP Listener: Receives HL7 messages from a socket
  • From HTTPS: Receives data from a web service
  • From Channel: Receives queued messages from another channel

All of these components have a built-in listening/receiving function, and when they get a message it is passed into main() using the Data parameter. The Translator simply mimics how these components run in a live situation by passing sample data to main() using the Data parameter.

A From Translator is different as it does not have a built-in listening/receiving function and uses code to grab data from disk (or web service etc.). The Translator again mimics the live behavior by not passing data to main() (hence no sample data), which is exactly how the live channel works.

Perhaps an example will help.

Let’s use a single line of code in an LLP Listener to parse an HL7 message.

First we show it using sample data, which works correctly:

Then without sample data which causes an error because the Data parameter is empty/blank:

Now let’s run the channel, and as you can see it works without error:

And when we put the same code in a From Translator component, it fails because there is no Data parameter:

Note: The error message indicates that the Data parameter is missing. This is because Iguana is not passing a value to main() and therefore the parameter is undefined (nil).

So let’s double check by running the channel, and as you can see it fails with the same error we saw in the Editor: