Support > Tutorial (R7) > Example of a customer management application > Item (repeat container) / model reference
ja | en

I will explain how to define Wagby's "repeating container".

Many business applications handle "item" information. Here, the item "refers to a certain group of data contained in the model.The item is strongly associated with the data (which stores it), and when you delete the data, the item data contained in it is deleted at the same time.

Here, we show an example of preparing a new model "business daily report" and handling the detailed information in the form of "visit history" in it. This visit history information can be described multiple times in one business daily report. Wagby defines such detail information as an item of "repeating container" type.

Prepare a new model "dailyreport".
We will make model name (Japanese) "business daily report".The model items are as follows.

Item name (Japanese) Item name (English) Item type Primary key
Business daily report ID dailyreportid Integer type
date date Date type
Person in charge staff Character type
Visit history visit Container of repetitive items
number visit/vid ID for repeated item container
client visit/vcustomer Item reference of another model (search screen)
Contents visit/vmemo String
For "Contents" item, select "New" from the gear icon and set after adding the input line.

For the items included in the repeating container, the item name (English) is "repeating container name +" / "+ item name".
The beginning of the repeating container defines the "ID for the repeated item container" to indicate the number (order) of that container.

Figure 1 Definition of "business daily report" model

Leave the type of the "customer" item initially as a string type.(Figure 1)
When the setting is over, change the type to "reference item of another model".(Figure 2)

Using Figure 2 "Reference item of another model" type

In the visit history, it is necessary to store the visit information "which customer visited".In this case, it is desirable to refer to already registered "customer" models.

By the way, it is expected that hundreds to tens of thousands of "customer" models will be operated.In such a case, we will use "(Search window using subwindow)" provided by Wagby.

Open the detail definition window for the item visit / vcustomer that stores the customer.
The input type is "search screen".
Specify the referenced model and referenced model item (which item value in the referenced model is displayed).

Figure 3 Detailed setting of customer item type

Follow the previous steps to build.

After building, start the Wagby application and log on. Select "Import and export" from the management processing menu.
Now restore the previous data.Specify the data saved in the previous tutorial as "import folder name".
Click the "select all" button and press the "Import" button with all models as the target.

Figure 4 Data Recovery

A new "business daily report" has been added to the "Service" tab of the menu.

Figure 5 Business Daily Report Search Screen

Open the new registration screen.

Fig. 6 Business daily report new registration screen

You can input date items by data picker function.

Figure 7 Data picker

A button called "Search ..." is prepared for the "customer" item in the repeat container "visit history".

Figure 8 Search customer model

When you press the search button, a subwindow like the one in Figure 8 opens.The search conditions on this screen are those specified by the search condition of the customer model.

Figure 9 Search window by subwindow

When you click the "To list display" button in Figure 9, the search results as shown in Figure 10 are displayed. "Customer name" is displayed in link format.You can search by pressing the target data (customer name).

Figure 10 Customer search results

Figure 11 shows an example of repeating this operation and creating two visit histories.

Figure 11 Example of entering visit history

To clear the customer information you entered, press the eraser icon provided on the left of the entry field.(FIGS. 12 and 13)

Figure 12 Eraser icon to clear input
Figure 13 Input cleared

Finally, I will explain how to change the position of the defined model item. Here we change the model definition so that the "date" item is part of the visit history.

I will return to WagbyDesigner.Drag the "date" item of the business daily report model with the mouse and drop it at the position where you want to insert it.(FIG. 17, FIG. 18)

Figure 17 Moving a Date Item (Drag)
Figure 18 Moving (dropping) date items

Change the item ID (English name).We will fit into the naming convention to enter the repeating container.Here we have "date" as "visit / vdate".I added "v" before date and changed it to vdate.

Figure 19 Changing item ID
The item ID has a rule that is unique in the entire model definition (ID is not duplicated).This rule applies to the remainder of the repeating container name.Since we used the item ID date first, changing it to vdate indicates "not the original name".

As before, I stop, build, and restart the Web application.
Figure 20 shows the new registration screen after correction.Since the date item entered in the visit history, it is possible to make multiple inputs.

Fig. 20 Business daily report new definition screen after definition change

Export and log off

Before proceeding to the next step, save the current data. Select "Import and export" from the management processing menu.Please select the target model "select all" and "export".

Figure 21 Management Process Menu

Log off from the application.Proceed to the next tutorial.

Figure 22 Logoff

"Frequently asked questions and answers> tutorialPlease read.