vartron
Posts: 7
|
Posted: 07/31/2014, 5:37 PM |
|
I have a record called xxyyzz, I need to join 2 or more fields and store them in a 3rd.
EXAMPLE.
Field 1 = Name
Field 2 = Name2
Field 3 = Name + Name2
All this before sending to save.
Sorry for my English
|
|
|
saseow
Posts: 744
|
Posted: 07/31/2014, 9:01 PM |
|
Try something like this:
In the On Validate event of the record form join the strings with PHP like:
$Container->Field3->SetValue($Container->Field1->GetValue()." ".$Container->Field2->GetValue());
That should work.
|
|
|
eratech
Posts: 513
|
Posted: 08/01/2014, 3:46 AM |
|
Or the same code in the Before Insert or Before Update events for the Record.
saseow - any reason you do it in the Validation instead of Before Update etc?
E
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia |
|
|
laneoc
Posts: 154
|
Posted: 08/01/2014, 12:42 PM |
|
Or use a trigger.
_________________
Lane |
|
|
saseow
Posts: 744
|
Posted: 08/01/2014, 9:53 PM |
|
No real reason why I would put it in On Validation other than laziness eratech. Before Insert is fine but I would also put it in Before update in case any of the single fields used was changed so a little more work to do. Using a trigger is also fine except requires a bit more typing.
Just laziness
|
|
|
eratech
Posts: 513
|
Posted: 08/03/2014, 3:06 AM |
|
You are right - you need to add it into both Update and Insert.
Was really just wondering if there was anything special, but laziness is something I can relate to.
Lane - a trigger would work, but I've steered away from DB triggers as they don't always travel well between DBs and it kind of hides the logic away in the DB.
cheers
E
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia |
|
|
vartron
Posts: 7
|
Posted: 08/05/2014, 7:03 AM |
|
Thank you very much, I did in the events, but I require to do the same in a custom insert or a custom update, with expressions. Can i do this.
Actually I require concatenate 2 ID and the last record ID. Do I require from a custom insert.
Example.
Control 1: 1
Control 2: 2
Metadata: 1-2-last_record_id
that's my problem.
Tks. to all
|
|
|
saseow
Posts: 744
|
Posted: 08/05/2014, 9:49 PM |
|
You can also join fields in an SQL statement using 'CONCAT' or 'CONCAT_WS'.
Google that and you will find tons of examples.
|
|
|
sorinbuda
Posts: 27
|
Posted: 06/03/2016, 11:49 AM |
|
Quote saseow:
Try something like this:
In the On Validate event of the record form join the strings with PHP like:
$Container->Field3->SetValue($Container->Field1->GetValue()." ".$Container->Field2->GetValue());
That should work.
That example works well in a Record but I can not make it work in a Editable Grid.
Do you have any idea why?
I already tried OnValidate, OnValidateRow at the EditableGrid level and OnValidate at the field level.
kind regards,
Sorin
|
|
|
sorinbuda
Posts: 27
|
Posted: 06/03/2016, 12:57 PM |
|
Solved with SQL in Custom Update
|
|
|