I have tried a scenario with a business data with multiple records, which can be empty if no one inserts records yet. In the edit form, it has to load from context using …/{{context.businessData_ref.link}} It is fine if there are at least 1 record.
But when the records are empty, the api will contain something like: “API/bdm/model/findByIds?ids=” which returns http error 400. The result variable which bound to repeating container will not allow adding rows.
I tested the variable become undefined in this scenario
Moreover, I want to reformat the structure the JSON structure for presentation. By returning from a javascript expression, the variable is read only.
I tried this method to solve it, but failed by hitting another problem:
Setting 2 variables:
DataListLoad (Ext API) = …/{{context.businessData_ref.link}}
DataListRestructure (javascript expression) = return reStructure($data.DataListLoad);
DataListInput (JSON) =
DummyTitle (javascript expression) = if ($data.DataListLoad !== undefined) $data.DataListInput = JSON.parse(JSON.stringify($data.DataListRestructure)); return “Form Title”; // this logic is to use a dummy title to trigger the evaluation of the variable and to deep copy the data if not empty
However the above settings suffers from AngularJS $digest mechanism. The DummyTitle is evaluated a multiple times and loop too much causing $rootScope:infdig
Please advise how should it be handled normally