Comparing values within a collection - Forum - Corticon - Progress Community

Comparing values within a collection


Comparing values within a collection

This question is not answered


I have a task where I need to iterate through a collection to determine if an amount is a credit (negative) and then, compare elements within that collection to those amongst that collection to determine if:

We get a collection of earning file details. Within these details, we have the fields:


  1. Detail_id
  2. Person_id
  3. Company_id
  4. Amount



I iterate though these records to see if there’s one with a credit (negative amount)

I label that record as a credit and now, I need to iterate through the rest of the records to see if the following is true:


  1. Credit person_id matches non-credit person_id
  2. Credit company_id matches non-credit company_id
  3. Credit amount matches non-credit amount (*-1)


I think I’m over thinking this. Realistically, we could have one or more credits. So, for every credit, I would need to loop through the details to see if I can find a non-credit match.

Thank you,


All Replies
  • Hi Branden,

    I am afraid that I do not understand your problem to give a clear solution. I will try, but I’m doing some assumption that might be incorrect. What I do notice is your technical approach to your solution (iteration, using ID’s).

    Since you’re using a rule engine instead of a programming language, I suppose you can reduce some complexity by using the vocabulary more to its advantage.

    Suppose you have two entities:

    1. PersonCompany

    -attribute: PersonId

    -attribute: CompanyId

    -relation: 1 to n to details

    2. Details


    Then you could use a single rulesheet with the following scope


    - Credit (Details)

    - - Amount

    - NonCredit (Details)

    - - Amount

    Filter for Credit: Amount < 0

    Fitler for NonCredit: Amount >= 0

    What is left are the PersonCompany instances with both Credit and NonCredit Details. You can apply any action you want.

    I hope this will help,