Concatenate Attributes

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
bkonia
Posts: 98
Joined: Fri Jan 19, 2007 4:41 am
Contact:

Concatenate Attributes

Post by bkonia »

Is there any way to concatenate two or more attributes that are displayed on a form? For example, I have a shortcut attribute, "FirstName" and a shortcut attribute, "LastName". On the form, I want to display the FirstName, then a space and then the LastName.

The way I'm doing it now is I have the two attributes in the same cell and I removed the label for LastName. The problem is that when it's rendered on the form, there is too much space in between the FirstName and LastName, so it looks weird.

I guess the simplest solution would be if you could fix this so it only inserts a single space in between two attributes that share the same cell. However, I'm surprised that there isn't any function like CONCATENATE(FirstName, ' ', LastName). Ideally, you would be able to create a shortcut called "Name" that contains a function like the one shown above.
Brad S Konia
Hostland
https://www.hostland.com
joftech
Posts: 117
Joined: Thu Oct 19, 2006 10:42 am
Location: Sydney
Contact:

Post by joftech »

Hi bkonia,

The way I have done this is to have an attribute called full name

I then have a rule in the business object that joins FirstName and Last Name.

The rule looks somethine like this. Lets say the business object is client.

client.fullename = client.firstname+' '+client.lastname

Alan
bkonia
Posts: 98
Joined: Fri Jan 19, 2007 4:41 am
Contact:

Post by bkonia »

Thank you, Alan. That's a bit of a workaround, but it does work perfectly. I would suggest to the AwareIM developers that they update the "Rule Language Reference" section in the manual to indicate that the plus operator can be used for string concatenation.
Brad S Konia
Hostland
https://www.hostland.com
bkonia
Posts: 98
Joined: Fri Jan 19, 2007 4:41 am
Contact:

Post by bkonia »

After implementing Alan's solution in my application, I came to the conclusion that this approach is far from ideal. The problem is that the developer is now forced to manually maintain the additional attributes and keep them in sync with the master attributes. For very simple applications, I suppose this is feasible, but as an application becomes more complex, you would end up with a complicated set of rules and every time you add a new form, you would have to attach rules to the form to keep the attributes in sync. It also presumes that the only place the attributes would be viewed is in a form, which is not the case.

For example, I have an attribute Client.FirstName and an attribute Client.LastName. Therefore, I create a new plain text attribute called Client.Name and use the following initialization rule:

Client.Name = Client.FirstName + ' ' + Client.LastName

Now, I can use Client.Name on my form to display the client's full name. This works fine during the initialization, but what happens if I edit the Client.FirstName or Client.LastName field on the Client form? Now the attributes are out-of-sync. Yes, I could attach another rule to the slave form that would re-sync the attributes the next time it's opened, but what happens if I run a query in the meantime? The query will display the old Client.Name value because it hasn't been synced yet. I could also create a rule that searches for all matching child attributes and updates them every time the master attribute changes, but the point is, this approach requires way too much maintenance on the part of the developer, stores redundant data, defeats the purpose of a relational database and ultimately will create a big mess.

Therefore, I would like to once again request that the AwareIM development team consider my initial feature request/bug fix:

Can you please fix the auto-generated form display so that when you have two or more attributes in a single cell, it only inserts a single space in between each attribute? Also, would you consider the idea of a "Calculated" attribute type that I described in the following message:

http://www.awareim.com/forum/viewtopic.php?t=1412
Brad S Konia
Hostland
https://www.hostland.com
joftech
Posts: 117
Joined: Thu Oct 19, 2006 10:42 am
Location: Sydney
Contact:

Post by joftech »

Hi bkonia,

Actually what you are saying is not quite correct. When you create a rule in a attribute there is a tab callled advanced. If you select the rule Client.Name = Client.FirstName + ' ' + Client.LastName and check use rule in dynamic recalculation on forms you will find that everytime you change firstname or last name the client.name will change automaticly.

Best Regards

Alan
bkonia
Posts: 98
Joined: Fri Jan 19, 2007 4:41 am
Contact:

Post by bkonia »

Alan,

Thank you again. You are indeed correct and I have implemented your solution. Nevertheless, it is still a workaround because it requires you to store redundant data in the database.

It would be better if there was an attribute type that would store a function, rather than storing data and then dynamically calculate the actual value each time the attribute is viewed.
Brad S Konia
Hostland
https://www.hostland.com
Post Reply