Rule to auto-populate an attribute

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
dianab
Posts: 23
Joined: Fri Nov 28, 2014 1:24 pm
Location: NC

Rule to auto-populate an attribute

Post by dianab »

I need a hint. I am playing around with the trial version once again (I seem to get too busy every time I try to start this project) I managed to create a dynamic choice based on a query. What I want to do is auto populate (for lack of a better word) another field based on what I choose from the dynamic choice.
Example:
I have a BO called Class with attributes of Name, Description, Type
I have created a dynamic choice for my appointment BO attribute "subject" which displays a dropdown list of all of the class objects I have created.
What I want to do is auto fill the "description" attribute based on the selection I made from the "subject" attribute.
I have tried with rules but I can't seem to find a rule that fits. I thought about creating a query that displays the description based on the subject attribute then have the result populate the "description" attribute but I can't seem to work it out.
I like to figure things out so I would prefer a hint then I can go back and see where I get but if you must lay it out there for me :D

Thanks,
Diana
BLOMASKY
Posts: 1478
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Re: Rule to auto-populate an attribute

Post by BLOMASKY »

IF BO.subject = 'XXX" then BO.description = 'YYY'
Create as many of these as you have choices

(of course, you could have 1 rule with a bunch of IF ... THEN ... ELSE IF THEN .... ELSE ..... but, you are a noob. create 3 rules and make your life easy

Make sure you check off use in forms so that it will update on the form as you make changes


Bruce
dianab
Posts: 23
Joined: Fri Nov 28, 2014 1:24 pm
Location: NC

Re: Rule to auto-populate an attribute

Post by dianab »

BLOMASKY wrote:IF BO.subject = 'XXX" then BO.description = 'YYY'
Create as many of these as you have choices

(of course, you could have 1 rule with a bunch of IF ... THEN ... ELSE IF THEN .... ELSE ..... but, you are a noob. create 3 rules and make your life easy

Make sure you check off use in forms so that it will update on the form as you make changes


Bruce
That will work but it is not the most practical of solutions becasue every time I add another class I have to change the rules unless I can add a rule for the rule.
What I was hoping for is something like this.
Find the record in the BO xxx that contains the class title selected in the BO yyyy then fill in the description with the description contained in that record.
Does that make sense?
BenHayat
Posts: 2749
Joined: Thu Dec 23, 2010 5:48 am
Location: Fla, USA
Contact:

Re: Rule to auto-populate an attribute

Post by BenHayat »

Diana, I assume you have a relationship between BO and CLASS Object, perhaps as "Peer".

Then in your rule, you can always get Class's Description and assign it to BO.Description.
For example, if you only want this to happen when BO is NEW, you can say,

IF BO IS NEW AND BO.Class IS DEFINED Then BO.Description = Class.Description.
And then for this rule, in advance tab, set the Dynamic rule on to show on the form immediately.

In here, I get a drop down of course templates (like your classes)
Image

Once I select it, then I get the "# of days" (like your Class description) and put it in my main BO.
Image
Jaymer
Posts: 2475
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Rule to auto-populate an attribute

Post by Jaymer »

BenHayat wrote:Diana, I assume you have a relationship between BO and CLASS Object, perhaps as "Peer".
IF BO IS NEW AND BO.Class IS DEFINED Then BO.Description = Class.Description.
And then for this rule, in advance tab, set the Dynamic rule on to show on the form immediately.
Ben,
since yours is looking for "NEW", how do you trap for when it is EDITED later?
varmod(x) is true and varcurr(x) <> varprev(x)

jaymer...
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
customaware
Posts: 2413
Joined: Mon Jul 02, 2012 12:24 am
Location: Ulaanbaatar, Mongolia

Re: Rule to auto-populate an attribute

Post by customaware »

you use WAS CHANGED Jaymer
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Image
Jaymer
Posts: 2475
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Rule to auto-populate an attribute

Post by Jaymer »

In a talk with Vlad, he said, w.r.t a list, is that WAS CHANGED refers to the SIZE of the list. If you add or delete a row in the list object, its fine. But if you edit a row, then the SIZE doesn't change and WAS CHANGED == false
Customer.om_Invoices WAS CHANGED is used for ADD/DELETE

ex.
customer BO
invoices BO, with transactions owned multiple by the parent

BruceL says this is the logic for doing this when a value in a list object is changed:
Invoices from Customer.om_Invoices was changed is used for EDITS in a row

Bruce says this is in the manual :)
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Post Reply