Menu

Iteration through arrays

Help
Luciano
2020-03-03
2020-04-30
  • Luciano

    Luciano - 2020-03-03

    Hi. I have a datatype which defines an array and another array inside ther first one. Then i use this data type on a spreadsheet. Inside this spreadsheet i'm calling a decision. The problem is that the first array is iterated but not the second one. Is this a correct behavior?


    Example

    DataTypes

    DataType SampleDataType
    String someField
    InnerDataType[] innerArray
    
    DataType InnerDataType
    Integer intValue
    

    Decision

    SimpleRules integer MiCustomDecision(integer count)
    
    count return
    1 10
    >1 20
    0

    SpreadSheet

    Spreadsheet SpreadsheetResult SampleSpreadSheet(SampleDataType[] items)
    myResultArray | sum(MiCustomDecision(items.innerArray.IntValue))

    If i execute this with 2 items i expect to sum the result of MiCustomDecision but i always get 0 beacause the second array isn't iterated

    Should it be iterated the second array? Is there any way to do this?

     
  • OpenL Tablets

    OpenL Tablets - 2020-04-29

    Hello,
    I've re-created a project based on given information, and it's failed to compiled with the error Method 'MiCustomDecision(java.lang.Integer[][])' is not found.
    I would recommend to use "flatten" operation which transforms 2d array into 1d.
    See example attached

    Please let me know will it work for your business case.

    Best Regards,
    Alena.

     
    • Luciano

      Luciano - 2020-04-30

      Thanks. i will try this

       

Log in to post a comment.