Edit an existing record and save it as a new record

Hi scriptcase,
How do I add a new button in form to add a new record starting from an existing one?

Example:
Edit record 21, then make changes and save it as a new record. In the end there are two records on 21 and the new one.

Sorry for my english

Re: Edit an existing record and save it as a new record

This form will have only this button? Or the others button will be available too?

You can create a new button called Duplicate(for example) of the type PHP …
if you a running under MySQL, you php code will be:
//if your fields is auto increment, otherwise you need to fill the primary key
sc_exec_sql(“INSERT table (field1, field2…) SELECT field1, field2 FROM table where key = ‘{key_field}’”);
//to get the last inserted key, if is mysql and if is auto increment
sc_lookup(rs, “SELECT LAST_INSERT_ID()”);

//now you can redir again to the form, opening in the new record
sc_redir("…/your_own_form/your_own_form.php?your_primary_key_field=" . {rs[0][0]} . “”);

Re: Edit an existing record and save it as a new record

Yes, I use mysql database.

This form will have others button: Duplicate, Update, Delete ecc…

You can add the option to duplicate records in the next version of scriptcase?

Thanks you.
D.