This is an old revision of the document!
Let ChatGTP or other LLM help with Back-End (Server-Side) JavaScript
ChatGTP and other LLM can be helpful when you need to write JavaScript code for MIStudio or TransSECS. Often ChatGTP can more easily generate valid Java code. There are a few steps to convert Java code into Javascript. The examples below assume the JavaScript engine in use is Nashorn (part of the JRE 8 runtime, which is the current Java version used in TransSECS, MIX and MIStudio).
Converting Java Code to Javascript
If you have a snippet or example of what you want to do written Java, there are a few changes which need to be done to make this run as JavaScript.
1. All Java classes need to be explicitly declared as either the full package name or as a var Java.type().
You can check the ErgoTech API for the full package names for vib or transsecs specific classes. The API is published here: https://www.ergotech.com/docs/api. You will notice these Java.type declarations at the top of many of the javascript examples published in this wiki, and also in the discussions of Value Objects. For example, for a LongValueObject, you will see:
var LongValueObject = Java.type("com.ergotech.vib.valueobjects.LongValueObject");
After this declaration at the top of the code, you can simply use “LongValueObject” when you need to use this class.