How to calculate the sum of successive specified inputs(only) while iterating a collection in Corticon? - Forum - Corticon - Progress Community

How to calculate the sum of successive specified inputs(only) while iterating a collection in Corticon?

 Forum

How to calculate the sum of successive specified inputs(only) while iterating a collection in Corticon?

This question is not answered

Here In my project, I need to add only the first two price of books of the library collection(for condition name="java") and return it in a decimal attribute(booksDecInfo)

If the iteration come across different name, the iteration must break.

Through this,

Though I have the same name, I must not add the 4th book's price to the returning value.

All Replies
  • Here’s one way to accomplish this.
    I’ve simplified the vocab for this example
    Remember that collections in Corticon are in an arbitrary order unless you explicitly sort them.
    So the question is “what do you mean by the first two java books”
    In this example I’ve sorted them by price and picked the first two.
    But you could also sort by any other attribute in the data (eg a sequence number)
    Notice also the use of the alias “javaBooks” along with the filter that defines what the alias actually means (type=’java’)
    Notice also that the filter on books is also carried up to the Library.
    Basically this says the rule sheet does not need to bother looking at libraries that have no java books at all.
    Test Case
     
     
     
     
  • Consider a collection in which we have name and price....

    The Specified name(in condition) may be found in many instances or it may not be present in the collection....

    If the first few attributes are with the specified name(in condition) and present subsequently, then I need the price values of those attributes to be added and displayed....

    And if the specified name is not found subsequently, I don't want my price to be added.......

    Here the important issue is >>>  For this process I don't want my collection to be sorted in any order.....