When tables are linked as parent <- child <- grandchild, the summary results of the grandchild table are not reflected in the parent table
Answer¶
Use "Script" or "Server Script".
Overview¶
When you have linked tables such as parent <-child <-grandchild, and you have set summary settings for each child and grandchild table, when you update a record in the grandchild table, the summary results will be reflected in the child table, but not in the parent table.
Example)
| Parent table | Child table | Grandchild table | |
|---|---|---|---|
| Summary settings | No settings | Reflect summary results in NumA of the parent table | Reflect summary results in NumA of the child table |
| Operation | No automatic update | Automatic update | ★Update manually |
| Numerical Value Column | NumA[0] | NumA[10] | NumA[10] |
The summary function can aggregate the data of the record itself in the record one level above, but it cannot process multiple levels at the same time, such as grandchild -> child -> parent. To reflect the summary results in the parent table, you need to set a script or server script that updates the child table as post-processing for updating the grandchild table. When a child table is updated, the parent table can be updated via the summary settings of the child table.
As an example, below is a sample code that automatically updates the child table when a grandchild table is updated when "ClassA" is a linked column with the child table.
Example 1. Script¶
Set the following script in the grandchild table. Check "New" or "Edit" as the output destination.
JavaScript¶
// After record creation, before the screen is updated
$p.events.before_set_Create = function () {
var recordId = $p.getControl('ClassA').val();
$p.ex.Update(recordId);
};
// After record update, before the screen is updated
$p.events.before_set_Update = function () {
var recordId = $p.getControl('ClassA').val();
$p.ex.Update(recordId);
};
// After record deletion, before the screen is updated
$p.events.before_set_Delete = function () {
var recordId = $p.getControl('ClassA');
$p.ex.Update(recordId);
};
// Method to update parent record (no data changes)
$p.ex.Update = function(recordId){
$p.apiUpdate({
'id': recordId,
'data': {}
});
};
Example 2. Server Script¶
Set the following server script for the grandchild table. Check the conditions "After creation", "After update", and "After deletion".