{{getMsg('Help_YouAreHere')}}:
/
{{page.title}}
{{page.title}}
{{$root.getMsg("downLoadHelpAsPdf")}}
{{helpModel.downloadHelpPdfDataStatus}}
JavaScript in i-net HelpDesk
JavaScripts in i-net HelpDesk must implement the function checkData(table, out) {}
function, which serves as the entry point. For the Status change trigger another function function getStatus() {}
must be written.
In these two functions the main logic of the script can be placed. Of course, it is possible that other functions are implemented and used for clean structuring. However, the two aforementioned functions are important as entry points. This is outlined in some examples.
The checkData
method is passed two parameters:
-
table
a hashtable with key/value entries -
out
a PrintStream on which debug output can be written.
Note: Values written back to the table
variable must be written as a string in the format "<value>"
or '<value>
'.
/** * Entry point into the JavaScript to execute logic. * There are two parameters and no return value: * * @param table java.util.Hashtable<String, String> Table containing field values, * which can be read and/or set. * Important: in the `table` there are no entries with `null` values. * @param out java.io.PrintStream Log stream that can be written to. */ function checkData(table, out) { table.get("<field>"); // Reading a value table.put("<field>", "<wert>"); // Writing a value out.println("<Message in server log>"); } /** * Entry point for 'Status in ticket changes'. Returns a list of statuses, * at which the trigger is to be executed. * * @return array with a number, equivalent to the ticked status. */ function getStatus() { // Trigger will be applied to this value only when it changes. return [<status>]; // list of status values is possible // return [<status 1>, <status 2>, <status 3>]; }
Check for availability of fields
To check the set values in the table
variable, you can proceed as follows:
-
The JavaScript associated with a trigger must be created or edited.
-
The triggers must be reloaded
-
The trigger must be fired, e.g. by manually sending a new email to the i-net HelpDesk.
/** * Entry point into the JavaScript to execute logic. * * @param table java.util.Hashtable<String, String> Table containing field values, * which can be read and/or set. * @param out java.io.PrintStream Log stream that can be written to. */ function checkData(table, out) { // ... // Here is further or already existing logic // ... // Additional function to print the current fields print_Parameters(table, out); } /** * Function to output all values in the table. * The values are output alphabetically sorted by key. * * @param table java.util.Hashtable<String, String> Table with field values, * that can be read and/or set. * @param out java.io.PrintStream Log stream that can be written to. */ function print_Parameters(table, out){ var tableKeys = java.util.Collections.list(table.keys()); java.util.Collections.sort(tableKeys); // alphabetische Ausgabe var it = tableKeys.iterator(); while( it.hasNext() ){ var key = it.next(); out.println("'" + key + "' -> '" + table.get(key) + "'"); } }