How to retrieve call specific value when .new[..] operator is used - Forum - Corticon - Progress Community

How to retrieve call specific value when .new[..] operator is used

 Forum

How to retrieve call specific value when .new[..] operator is used

  • For example:

    I have an entity (entity1) with attribute (a=60) .

    then i have used .new operator to create three entities.

    2.entity1.new[a=20] ,

    3. entity1.new[a=30]

    4.entity1.new[a=40] 

    Here i need to add the value " 1st entity1 and 3rd entity value" i don't want 2nd and 4th value.

    Note: The values are added to the same entity and in random memory. each time the ruletest is compiled the value of a changes

    I need to get the specific values and also use it in some other calculations

  • How are you able to distinguish the first and third entity from the second and fourth?
    Is there some other attribute in those entities that can be used to decide which values you want to add and which ones you don’t.
    You will need some way to distinguish them
     
    Here’s one way to do it:
    For example a Boolean attribute “includeInTotal”
     
    Then in the scope of your rule sheet you can do define an aliases (oldEntity) for the old entity (the one you want to add the totals to)
    And an alias for the entities that you want included in the total (otherEntity)
    The filter specifies that the “otherEntity” is any that are flagged to be included
    And the “oldEntity” is the one that is flagged as old.
    The filter section then uses the “old” attribute and the “includeInTotal” attribute to create two subsets of all the entities.
    Presumably there is only one “old” entity but possibly many to be included in the total
     
    Now in the rule sheet itself you can simply calculate the sum of all the entities that are flagged to be included in the total.
     
    So in this test case only the entities identified as “includeInTotal” (2 and 5) have been added to the entity identified as “old” (1) 20 + 100 + 60
    4. 6 and 7 were ignored.