User Manual

08.14.2024

MANUAL

FAQ: 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](/en/manual/table-management-script)" or "[Server Script](/en/manual/table-management-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 value A of the parent table|Reflect summary results in value A of the child table| |Operation|No automatic update|Automatic update|★Update manually| |Numeric item|Numeric A[0]|Numeric A[10]|Numeric A[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 "Classification A" is a linked item 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". ##### JavaScript ``` const records = items.Get(model.ClassA); if (records.Length === 1) { let record = records[0]; record.Update(); } ```
TOP
このページをシェアする
記載された商品名、各製品名は各社の登録商標または商標です。 © Implem Inc.