Support > Repository > Business logic > Initial value

I will explain the initial value How to write a repository using a script. R7.9

Initialization processing can be described as script code.

Figure 1 Script description field

The process written here is based on the initialization process set in DesignerlaterIt will be executed.

When you modify the script in Designer, it is immediately reflected in the application on the development machine.You can check the fix without building process.

In the script, "object" corresponding to the model name can be used.

When using the script in Figure 1, the generation of the target object is completed (because the automatically generated code is done) and only adds the process of setting the value.

However, there are cases in which a developer himself/herself wants to generate an object (using the new operator) in a script.In this case, we will explain how to perform initial setting of the initial value set in Designer.

var customerClass = Java.type("jp.jasminesoft.wagby.model.customer.Customer");
var customer = new customerClass();

var helper = p.appctx.getBean("CustomerHelper");
helper.initialize(customer, p);

By executing helper.initialize (), the value of the initial value (in the registration screen display) defined in Designer is set. For models that use group authority etc., values ​​such as "data owner" are also set at this timing.

A child model linked with a foreign key "Concurrent update function of foreign key> Initial display number"N sets of child model records are created at the same time when a new parent model is created.

At this time, the script that sets different values ​​for each element of the child model is as follows.(Child model name is child.It is assumed that the item item 1 is prepared for the child model.)

var count = p.request.getAttribute("_child_ulp_count");
if (count != null) {
    child.item1 = count;

On the parent-child simultaneous update screen, the element number of the target child model is included in the request object with the following name.The value is of integer type.


You can use this to find out what number of child models to target.