How do I number child relationships?

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
BobK
Posts: 545
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

How do I number child relationships?

Post by BobK »

I have 2 BO's: Trip and Route. Trip owns Route and is a 1 to many relationship. Trip has the following attributes: NumberOfRoutes (type number) and Routes (type Route). Route has the following attributes: StopNumber (type number) and Trip (type Trip). Trip.NumberOfRoutes will contain the number or Route records for this trip. Each Route will be numbered 1, 2, 3, etc for each trip and this will be stored in the Route.StopNumber.

I thought the following rule in Route would accomplish this:
If Route.StopNumber IS UNDEFINED Then
Route.StopNumber=Route.Trip.NumberOfRoutes+1
Route.Trip.NumberOfRoutes=Route.StopNumber

The form to create a Trip has the Routes attribute displayed as Table of Items with a 'Add New' button.

Each time I press the 'Add New' button, a new route is created but the StopNumber for each is set to 1.
The following is from the log:
Executing action Route.Trip.NumberOfRoutes=Route.StopNumber from rules of object Route
-Unable to find Business objects to modify attribute Route.Trip.NumberOfRoutes

I have tried everything I can think of to get this to work but have failed miserably.
Any help would be greatly appreciated.

Additional information:
After pressing the 'Create' button to create the trip, the following appears in the log:
Processing cross reference...

Is this when the link between Trip and Route is actually established?
Bob
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Post by tford »

Would this rule meet your requirement?

If Route IS NEW Then
Route.StopNumber=MAX Route.StopNumber WHERE (Route.Trip=ThisRoute.Trip)+1
Tom - V8.8 build 3137 - MySql / PostGres
BobK
Posts: 545
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Post by BobK »

Sorry Tom, that did not work. Each Route is still being numbered as 1.
Bob
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Post by tford »

Bobk,

I discovered that it won't work for new Trips, but should work when you add Routes to an existing trip. Is that what you are experiencing?

I have to run at the moment. If you need help later tweaking it to also work for new Trips, let me know.
Tom - V8.8 build 3137 - MySql / PostGres
BobK
Posts: 545
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Post by BobK »

Yes, I need HELP!

It is important that this work for new trips, but I can't even get it to work when adding routes to an existing trip. Tom, did you change anything on the Advanced tab for the rule?
Bob
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Post by tford »

Hi Bob,

Did you put the rule I gave you on the Route BO? Make sure any other Route rules that begin with 'Route.StopNumber=' are removed.

No advanced tab changes were made.

To get it to work with a new trip, use a process like:
ENTER NEW Trip USING 'Trip with no routes'
EDIT Trip USING Main

In this case, 'Trip with no routes' is a form that does not include the Routes attribute. You will just be creating a 'shell' Trip in the first step in the process, then editing the Routes in the second step.
Tom - V8.8 build 3137 - MySql / PostGres
BobK
Posts: 545
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Post by BobK »

I am finally getting back to this.

First of all I would like to thank Tom for his help.

Secondly, I got this to work if I do not allow inline editing on Routes. If I allow inline editing, it does not work. With inline editing, the StopNumber is always set to 1.

I would really like to use inline editing if at all possible, any suggestions?
Bob
Post Reply