JSDO 6.0 is now available from npm as the following packages:
Resources:
Please let us know if you have any feedback.
You can leave comments or questions directly on GitHub (where the source code is maintained) by opening an Issue.
Is it possible to read nested data out of the jsdo? I use the jsdo directly and my dataset looks like this:
define dataset dsVS_CallLine
for ttVS_CallLine,
ttDM_RecordMetaData
data-relation drRecord for ttVS_CallLine,ttDM_RecordMetaData
relation-fields (vst_callposition_obj,Owning_Obj) nested.
Unforrtunately the jsdo["ttVS_CallLine"].getData().record doesn't contain the nested data. And even worse, jsdo["ttDM_RecordMetaData"].record is undefined, although the read request went through and shows the data in the network tab of my browser.
{ "dsVS_CallLine": {
"prods:hasChanges": true,
"ttVS_CallLine": [
{ "linenumber": 1.0,
"part": "1300010",
"part_info": "",
"quantity": 3.0,
"unitofmeasure": 0,
"unitofmeasure_info": "",
"viewid": "110",
"vst_call_obj": "PA2036:pA:8acea1a7002696acdc111bb9f297822a",
"vst_callposition_obj": "PA2037:pA:8acea1a7002696acdc111bb9f397822a",
"adoptedquantity": 0.0,
"refdoc_origin_obj": "",
"origin_obj": "" } ],
"ttDM_RecordMetaData": [
{ "Owning_Obj": "PA2037:pA:8acea1a7002696acdc111bb9f397822a",
"Table_ID": "ttVS_CallLine",
"Field_ID": "quantity ",
"AttributeName": "HolleBolle",
"AttributeValue": "testValue" } ],
"prods:before": { } }}
Is this expected behavior?
Hello,
Yes, it is possible.
There are two ways that you can work with the nested data:
1) When there is a current working record select for the parent table, you can use getData() on the child table to get the related records.
No records are returned for the child table if there is no selected working record on the parent table.
2) You can also turn off the usage of the relationship by setting jsdo.useRelationships to false. In this case, a call to getData() on the child table returns all the records.
Related link:
* documentation.progress.com/.../
Note: The JSDO perform this behavior regardless of the usage of the "nested" keyword. The "nested" keyword determines the JSON format, however, the relation is always handled.
> Unforrtunately the jsdo["ttVS_CallLine"].getData().record doesn't contain the nested data. And even worse, jsdo["ttDM_RecordMetaData"].record is undefined,
> although the read request went through and shows the data in the network tab of my browser.
Please notice that getData().record is not valid - you should do something like jsdo["ttVS_CallLine"].getData() or jsdo["ttDM_RecordMetaData"].getData().
Please check and see if it is an issue with the way the API is being called.
I hope this helps.
Hi Edsel,
thanks for your answer. The following code works for me now:
jsdo.useRelationships = true;
jsdo.fill();
let mData: DataResult = jsdo["ttDM_ChildTableOne"].getData();
with a dataset defined in the ABL-BAckend like:
define dataset dsVS_CallLine
for ttVS_CallLine,
ttDM_ChildTableOne
data-relation drRecord for ttVS_CallLine,ttDM_ChildTableOne
relation-fields (vst_callposition_obj,Owning_Obj) nested.
But in my application the dataset actually is defined like this:
define dataset dsVS_CallLine
for ttVS_CallLine,
ttDM_ChildTableOne,
ttDM_ChildTableTwo
data-relation drRecord for ttVS_CallLine,ttDM_ChildTableOne
relation-fields (vst_callposition_obj,Owning_Obj) nested.
data-relation drRecord for ttVS_CallLine,ttDM_ChildTableTwo
relation-fields (viewId,iewId) .
Then the code only works, if I leave out the "nested" keyword in the dataset definition. Despite which value the useRelationships property has. Is this expected to work only with one relation? Additionally, with useRelationships = true und a nested relation I expect a call to jsdo["ttDM_ParentTable"].getData() to retrieve both the parent record and the child record in a nested array. Am I wrong?
Regards,
Hans
Hello Hans,
The code should work with the nested keyword and without.
You should be able to access data on the 3 table references.
Internally, the JSDO loads the JSON payload and creates data arrays for each of the temp-tables.
The internal structure is the same whether or not the nested keyword is used.
Please notice that the call to getData() only retrieves the records of the specified table reference. It does not include the child records in a nested array. This could be a nice enhancement.
You can submit an enhancement via the Issues system: github.com/.../issues.
In order to get the child records, you would call getData() on the table reference of the child once a working record for the parent table reference has been set by performing fill(), foreach(), find() or findById().
(getData() does not set the working record.)
I hope this helps.