You are here: Infrastructure > 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 on a feature's attributes.

The only portion of JavaScript supported is that in the ECMA-262 specification, no HTTP or DOM support is provided. Usual objects and methods provided by a browser environment, such as document() or XMLHTTPRequest() are unavailable.

The primary power of the JavaScriptCaller is to allow users who are comfortable with JavaScript notation to perform attribute manipulation using calls such as JSON.parse() and JSON.stringify(). Custom functions for logging, getting, and setting attributes are offered in the form of fme_ functions.

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


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!");


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.



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.



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


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.