Add / copy row with PK

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
geologic
User
Posts: 45

Add / copy row with PK

Post by geologic »

Hi

I have a table with one PK that is set at code with the concatenation of 2 fields. I make the concatenation at Row_inserting event:

function Row_Inserting($rsold, &$rsnew) {
$rsnew['CODE']=trim($rsnew['FIELD1'] . " " . $rsnew['FIELD2']);

It works when i add a new record but if i use de "copy" button, even i change the field1 and field2 (to create a new PK and new record) it sends me an error "duplicate primary key".

So, it works ok to new record but doesn't work for copy to a new record...

Regards


mobhar
User
Posts: 11768

Post by mobhar »

Have you tried by using "Row_Inserted" instead?


geologic
User
Posts: 45

Post by geologic »

I cannot set a Primary key after the row has been inserted...


mobhar
User
Posts: 11768

Post by mobhar »

In "Row_Rendered" server event, please insert the following code:

if (CurrentPageID() == "add") {
$this->CODE->EditValue = "test"; // just a temporary value!
}

This will provide a temporary value for the CODE field, so that the code in your "Row_Inserting" will then work properly.


geologic
User
Posts: 45

Post by geologic »

Great, worked!

Thanks


Post Reply