You are here: Workflows > JavaScriptCaller

JavaScriptCaller

Executes a JavaScript script to manipulate the feature. When a specialized task is required, such as custom statistical analysis of an attribute, but Workbench does not provide a transformer suited to the task, JavaScript can perform specialized and complex operations.

Any exceptions generated while running the script will cause the translation to fail.

Note: Using JavaScript to perform arbitrary operations on feature attributes is a powerful aspect of Workbench. However, the logic introduced into a workspace is less visible and can therefore be more difficult to maintain than logic built using Workbench’s built-in transformers. It is recommended that other transformers be used when possible instead of JavaScript.

Input Ports

Output Ports

Parameters

V8 Engine FME JavaScript Functions

print Function

The print function has been implemented to print out a custom log message to the standard FME log file.

print("Hello World!");

print(fme_get_attribute("color"));

fme_get_attribute Function

The fme_get_attribute function has been implemented to retrieve an attribute value as an encoded UTF-8 string from the current feature, given a single parameter containing the attribute name string.

print(fme_get_attribute("color"));

>"0,0,1"

fme_set_attribute Function

The fme_set_attribute function has been implemented to set an attribute name and value as an encoded UTF-8 string attribute on the current feature, given two parameters containing the attribute name and value strings.

fme_set_attribute("color", "red");

fme_attribute_exists Function

The fme_attribute_exists function checks whether the specified attribute exists on the current feature, and returns true or false depending on whether it does.

print(fme_attribute_exists("foo"));

>false

Editing Transformer Parameters

Using a set of menu options, transformer parameters can be assigned by referencing other elements in the workspace. More advanced functions, such as an advanced editor and an arithmetic editor, are also available in some transformers. To access a menu of these options, click beside the applicable parameter. For more information, see Transformer Parameter Menu Options.

Transformer Categories

Web

Workflows

FME Licensing Level

FME Professional edition and above

Search FME Knowledge Center

Search for samples and information about this transformer on the FME Knowledge Center.