BIRT JSON DATA IN LOOP

Hi All,

I have a requirement where I am getting JSON data and need to show it in table. JSON which as list within list

var i;
var j;
var k;
for (k = 0; k < myJSONObject.releasePackage.length; k++) {
for (i = 0; i < myJSONObject.releasePackage[k].paymentTerms.length; i++) {
for (j = 0; j < myJSONObject.releasePackage[k].paymentTerms[i].salesOrderItems.length; j++) {

    }

}
}

How can I use it in fetch of scripted data source?

I need data as

col1 : release package id
col2 : payment term id
col3 : sales order item id

Number of records will be equal to sum of all sales order items in all payment terms in all release packages.

If any sample available, request you to share same.

Answers

  • In the inner "for" loop, you could add the following code:

    row.col1 = myJSONObject.releasePackage[k];
    row.col2 =myJSONObject.releasePackage[k].paymentTermse[i];
    row.col3 = myJSONObject.releasePackage[k].paymentTerms[i].salesOrderItems[j];
    

    This code is untested. Please test it with your data. Once you create the table, you can create groups on release package id and payment term id to avoid displaying many duplicate values.

    Jeff F.
    Customer Support Engineer I
    OpenText
Sign In or Register to comment.