Support > Repository > Form > Script to customize the output of the form
ja | en

You can customize the contents of the form output data using a script. R7.9

Choose "Edit form contents" from "Screen> Script> Helper".

Figure 1 Writing a script

For details on how to write scripts, see "Business logicPlease read.

When the script is called

The script created here will be called just before the standard form data is prepared after pressing the form button and just before that data is passed to the printing process.Therefore, standard form data can be replaced.

Objects available in script

The following objects are available in the script.

REPLACEMAP

A map (java.util.Map) that stores strings for keys and values.The key part has the following naming convention.

Key notation Description
$ {Model ID_p. Item ID} Contents of detailed display
$ {Model ID_lp. Line number. Item ID} Contents of list display
$ {Model ID_cp. Item ID} Contents of the search condition of the list display.In the range search, "1 jshparam" and "2 jshparam" are added to the end of the item ID.

REPLACEMAPTYPE

A map (java.util.Map) containing item type information.The key part rule is the same as REPLACEMAP.The value part becomes type information.

Example 1 Displaying the contents of REPLACEMAP on the console

The entity of REPLACEMAP is java.util.Map.Therefore, you can manipulate map using java.util.Iterator.

var it = REPLACEMAP.keySet().iterator();
while (it.hasNext()) {
  var key = it.next();
  var value = REPLACEMAP.get(key);
  stdout.println(key+"="+value);
}

Example 2 Modifying the content of REPLACEMAP

The next example is to give the "*" character to all values.

var it = REPLACEMAP.keySet().iterator();
while (it.hasNext()) {
  var key = it.next();
  var value = REPLACEMAP.get(key);
  value = value + "*";
  REPLACEMAP.put(key,value);
}

Error handling

Returning an arbitrary character string with a return statement in the script will treat it as an error.At this time, a BusinessLogicException occurs during script execution.This is logged as an error in the log (system.log).

In addition, you can prepare an error message displayed on the screen in the script.

var error = new Jfcerror();
error.content="エラーです";
p.errors.addJfcerror(error);

return "ERROR!";
By applying this mechanism, if the contents of the form output matches a certain condition, it can be set as an error without outputting it, and an error message can be displayed on the screen.