Second object in the context is a list

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
Chris
Posts: 6
Joined: Thu May 22, 2008 4:03 pm

Second object in the context is a list

Post by Chris »

Hi,

This is a rule attatched to an object called 'Object':)

1st case :

If
Object IS NEW
Then
FIND Object WHERE Object.NumberAttribute<300 AND Object.ID<>ThisObject.ID
REDUCE Object.NumberAttribute BY ThisObject.NumberAttribute

Important : ThisObject can't be find by the FIND action.
In this case, the REDUCE action occurs on all Object in the context, that is to say ThisObject and all object find by the FIND action.

2nd case:

If
Object IS NEW
Then
FIND Object WHERE Object.NumberAttribute<300 AND Object.ID<>ThisObject.ID
REDUCE ThatObject.NumberAttribute BY ThisObject.NumberAttribute

In this case, the REDUCE action only occurs on the first Object find by the FIND action (Object with the lowest ID I think). In fact, That prefixe referes to the second object in the context.

So, my question is, when the first object in the context has the same type as a list inserted in the context just after, is there an elegant way to apply an action on this list only?

Warm regards,
Christophe
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Post by tford »

Christophe,

Here is one way to solve it:

1- Create another non persisted BO called NewInfo with 2 attributes:
a- NewID - number
b- NewNumber - number

2- Create 3 processes:
a- ProcessNewObject2
--- 2 inputs for this process: NewInfo & Object
--- 1 rule: REDUCE Object.NumberAttribute BY NewInfo.NewNumber

b- ProcessNewObject
--- 1 input for this process: NewInfo
--- 2 rules as follows:
FIND Object WHERE Object.NumberAttribute<300 AND Object.ID<>NewInfo.NewID
ProcessNewObject2

c- EnterNewObject
--- No Inputs
--- 3 rules as follows:
ENTER NEW Object USING Main
CREATE NewInfo WITH NewInfo.NewID=Object.ID,NewInfo.NewNumber=Object.NumberAttribute
ProcessNewObject

To create new objects, you will run the process called EnterNewObject.

You will remove the rules in the Object BO & just let these 3 processes to all the work.

Tom
Chris
Posts: 6
Joined: Thu May 22, 2008 4:03 pm

Post by Chris »

Thanks for your idea Tom,
I modified it a little bit and it exactly does what I wanted.
However, an Instance Prefixe 'These' would have been more efficient.

Cheers,
Chris
Post Reply