You can link the title of the model that links with the "customer" model with the foreign key, the title of the list of "support".
Figure 1 Title becomes link
By clicking on the link you will be taken to the "support" list display screen.You can check the list you were checking on the detail display screen of "customer".
Fig. 2 Transition to list display screen
Let's see the search screen next.You can see that the "customer ID" displayed in Figure 1 is automatically set.
Figure 3 Support search screen
On the support model side (child), specify the "customer ID" (primary key of the customer model) as the foreign key as the search condition.
Figure 4 Include customer ID (in support model) in search criteria
Opens the model item detail definition dialog for the foreign key item.
Activate "Save details in database when registering details> in database".
Figure 5 Setting to save the value in the database at registration
Precautions on setting
This setting must satisfy all of the following conditions.
Child models do not use tab display.It is a system to arrange vertically and display a list.
The child model has a search screen.
The foreign key is defined as a search item.
The search condition of the foreign key must be checked for "Equal expression" setting on the search control tab of the item detail definition is "equal" or "Perform range search".(Note: When the foreign key is a character string type, by default the "conditional expression" setting is "partial match of character string", so change the definition to "equal".)
Mandatory checks are not defined for search items excluding foreign keys.Specifically, "mandatory check" on the search control tab of the item detail definition is not defined.
Change name of child model list
An example of changing the list display name of the child model to "customer-specific support history list" is shown below.
Figure 6 Changing the list display name
Set up the support model "Search/list display> foreign key linkage> list name".
Figure 7 Setting the list name
Restrict the number of items to display list data
An example in which the maximum number of items displayed in the child model is set to 1 is shown below.
Fig. 8 Set the maximum number of display items of the child model as 1
Data that was not displayed can be checked on the search screen of the support model.
Figure 9 Checking other data on the support model search screen
Set up "support/list display> external key cooperation> maximum display number" of the support model.In this example it is "1".
Figure 10 Setting the maximum number of displayed items
Figure 11 shows an example of adding explanatory text to Figure 8.
Fig. 11 Add descriptive text to the child model list display
Set up "support/list display> external key cooperation> explanation" of the support model.At the same time, you can specify the style.
Figure 12 Specifying descriptions and styles
Control the display of buttons
Create a new child model
To create a child model in external key cooperation, you can use the "Create New" button displayed on the detail display screen of the parent model.I will explain how to not display this button.
Figure 13 Example in which the new creation button is not displayed
Disable the support model "new registration> external key cooperation> new registration button to be displayed on the parent model's detailed display screen".(It is enabled by default.)
Figure 14 Setting the new registration button to be displayed on the detailed display screen of the parent model
It is possible not to display the button which transitions to the list display/detail screen of the parent model prepared on the detail screen of the child model.
Figure 15 Example in which the transition button to the parent model is not displayed
Disable the support model's "Detailed display> Foreign key cooperation> Parent model list display button" and "Detailed display> Foreign key cooperation> Parent model detail display button".(It is enabled by default.)
Figure 16 Setting the list display button and detail display button of the parent model
Do not display the data list of the child model on the screen of the parent model
In addition to the settings shown in Figure 14 (hide the "Create New" button), you can also set not to display the child model list.As shown in Figure 17, the existence of parent-child model relationship can not be recognized from the screen.
Figure 17 Example in which the new creation button is not created and the child model list display is also not displayed
>>Unlock the "Display" setting in the data list to be displayed on the parent model's detailed display screen.
Figure 18 Setting the data list to be displayed on the detailed display screen of the parent model
With foreign key relationships, when deleting parent model data, child models are also deleted at the same time.
An example of deleting the parent model "customer" is shown in Fig. 19 and Fig.
Figure 19 Deleting customer data
Figure 20 Successful Deletion of Customer Data
We will confirm the support model here. You can see that the child model (support) has also been deleted.
Figure 21 Child model "Support" has also been deleted at the same time
"Other> Relationships of the model> Automatically delete when deleting the parent model" is confirmed.It is enabled by default.If you cancel this setting, the child model will remain even if you delete the data of the parent model.(However, in this case, the state that parent tied data does not exist.)
Figure 22 Setting to delete automatically when parent model is deleted
With parent - child - grandchild relationship, all descendants associated with it are deleted when parent is deleted.
Recalculation specification (parent)
With the timing of registration, update and deletion of the child model, it is possible to recalculate and resave the item values of the parent model side.
Figure 23 shows an example of managing the number of support as child models by customers who are parent models.
Figure 23 Adding support items
If you add support, the value of "Support cases" will also increase.At the time of this registration, update and deletion, the item values on the parent model side are recalculated and re-saved.
Figure 24 Support Count Item recalculated
Add "support count" item to parent customer model.It saves it in the database, and the formula uses the COUNT function.
Figure 25 Definition of number of support items
Support modelEnable "Updating parent model when changing> Screen> Other>".(By default, this value is enabled.)
Figure 26 Setting to update parent model when changing
This setting works because the "number of support cases" item is saved in the database.Calculation is executed regardless of this setting, because it is always recalculated at the time of display in case of non-database saving.
This setting is recalculated retroactively to the ancestor if the parent is further daisy.
The "brother" data of the child data linked to the parent is not subject to recalculation.
This process is not performed when registering/updating with a child model alone.For example, when registering a child model by receiving mail, the parent model is not recalculated.
Recalculation specification (child)
At the timing of registration, update and deletion of the parent model, it is possible to recalculate and resave the item values on the child model side.
The child recalculation function becomes effective when the following conditions are satisfied.
A list update screen of child models has been created.
Simultaneous updating function of foreign key is enabled in list update of child model.