Editing a JavaScript Business Rule Externally
Business Rule JavaScript operations can be edited externally via the Edit Externally action found on the Business Rule / Business Function tab.
Prerequisites
In order to use this feature, Visual Studio Code must be installed and set as the default program for JavaScript (.js) files. Clicking the Edit Externally button without setting a default program for .js files will result in an error.
Important: Any program other than Visual Studio Code is unlikely to offer the auto-completion and embedded documentation capabilities described below.
Using an External Editor
After clicking Edit Externally button, a temporary JavaScript file is generated and opened in Visual Studio Code.
This temporary file has access to additional features, such as code auto-completion and embedded documentation, which can assist users that are not familiar with the Public API. Code auto-completion is generated from STEP JavaScript API content, as well as from binds and associated Business Libraries (if any dependencies are defined on the business rule), and assists the user with writing JavaScript code relevant to business rules.
Note: Auto-completion may not be available for every method.
Embedded documentation provides the user with additional context for elements in their JavaScript code, such as: parameter type, method descriptions, return type, and any exceptions that may be encountered.
Note: If elements are associated with a library for which a dependency has been defined in STEP, the associated information will only display if the library code has been documented.
After opening an operation in Visual Studio Code, an 'Edit js file' prompt will appear in STEP, and remain until the user either clicks OK to accept changes made to the JavaScript file or Cancel to disregard changes.
Important: Be sure to save any desired changes to the file in Visual Studio Code before selecting OK in STEP.
Once a selection is made, the temporary file is deleted.
Note: JavaScript binds should be defined in STEP, however they are recognized in Visual Studio Code. This is made possible by auxiliary files downloaded alongside the js file. Those files (e.g. js doc, js file, library js file, etc.) should not be edited, as only the business rule js operation file is saved back into STEP.
Note: To facilitate easier editing of the code, the JavaScript classes available in Visual Studio Code are JavaScript stubs. These stubs contain the public API method names and java docs of the java classes that are used at runtime when executing the business rule. However, these stubs are not executable, and while they are treated as root level classes in the Visual Studio Code editor’s environment, they do not exist at runtime when the business rule is executed.
For example, writing 'var product = new Product();' might look correct in the editor, but will yield a runtime error during execution because 'Product' does not exist as a root level class at runtime. Almost all Public API object instances are obtained at runtime using the bindings defined for the business rule, or through methods called on other Public API object instances originating from a binding.