Support > Repository > Form > Script to customize the output of the form

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

Please read "Business Logic" for how to write script.

When the script is called

The created script is called just before standard document data is prepared after pressing the document button and just before the 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.

Placeholder jshfilename: image notationYou can also specify the display range in the script, not the one.Script settings take precedence.

REPLACEMAP.put("${customer_p.phhoto_jshfilename:image:col}","10");
REPLACEMAP.put("${customer_p.phhoto_jshfilename:image:row}","10");
REPLACEMAP.put("${customer_p.phhoto_jshfilename:image:sx}","0.5");
REPLACEMAP.put("${customer_p.phhoto_jshfilename:image:sy}","0.5");

The value isStringSo you need to enclose it in double quotes.

If jshfilename: image is not specified in the placeholder of the form template, the above setting will be ignored.