Default Calculated Attribute

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
thom
Posts: 89
Joined: Fri Sep 12, 2008 4:51 pm
Location: Boston

Default Calculated Attribute

Post by thom »

I am having trouble tackling a couple of things regarding the syntax of a rule for a calculated field as well as how to see the calculated value prior to saving.

I have an attribute (SortOrder) that allows the user to control how the order of specific related BO appears (an event is made up of a number workshops). When the user is entering a new workshop, I would like them to see the SortOrder as a defaulted as the max +1, but the rule I have written is giving me max + 1 sortorder for the entire entitty, not the event

IF Workshop IS NEW THEN Workshop.SortOrder = MAX Workshop.SortOrder +1

How do i get this to group on the Event so the sortorder is sequential for the event.

Also, when adding a new Workshop, I would like to the SortOrder rule to default the value so the user can see it prior to saving the record - there are cases where they will change on new/
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Post by tford »

thom,

Is Workshop BO owned by Entity BO?

You also mention that it's a calculated value but later say that there are cases where you will change the value. You can't do both. Can you please clarify your needs.
Tom - V8.8 build 3137 - MySql / PostGres
thom
Posts: 89
Joined: Fri Sep 12, 2008 4:51 pm
Location: Boston

Post by thom »

Hi Tom,

Yes - Workshops is owned by Events.

I did not convey the nature of the SortOrder field correctly - it is not marked as a calculated field although I used a rule to update. That provides me the ability to have the value set, and the ability on Edit to change it. I would prefer to "see" the rule apply during the add process and that way the user could make the proper adjustment if needed

thanks
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Post by tford »

thom,

Try this:

1) Workshop rule:
If Workshop IS NEW Then
Workshop.SortOrder=MAX Workshop.SortOrder WHERE (Workshop.Entity=ThisWorkshop.Entity)+1

In the Advanced tab for this rule, check "Use rule during initialization"

2) Process named NewWorkshop:
CREATE Workshop WITH Workshop.Entity=Entity
EDIT Workshop USING Main

This rule will have Entity as a Process Input.


3) If you run process from #2 above when an Entity is in context (from an Entity form or Query, the SortOrder should default properly.
Tom - V8.8 build 3137 - MySql / PostGres
thom
Posts: 89
Joined: Fri Sep 12, 2008 4:51 pm
Location: Boston

Post by thom »

Tom,

I thought we had it, but I must be doing something wrong.

I updated the rule to include the where clause (which I previously tried but got nothing to return) and I check the "Use rule during Initialization " - thanks for that one, I never noticed the Advance tab before...obvious

My process was set as you recommended - upon adding a new workshop the SortOrder always defaults to 1 - whether it is the 1st or 20th workshop added for the event.

did i miss something? Thanks

thom
thom
Posts: 89
Joined: Fri Sep 12, 2008 4:51 pm
Location: Boston

Post by thom »

Tom,

Sorry I forgot to post that your solution worked. Thanks for the sample bsv

thom
Post Reply