Page 2 of 2

Re: Clone not working

Posted: Thu May 31, 2018 3:01 pm
by marcvander
Hey toms,

so I have done the following, and it seems to work:

-I dropped all foreign keys constraints of all primary keys which were int(11) auto_increment
-I changed all previous foreign keys to varchar(25) and all primary keys to varchar(25)
-I added again all the foreign keys constraints

Like this, I didn't lose any linked tables. The old values still have the values of auto_increment, and the new ones will have a unique hash id.

Now I can clone simple forms which don't contain any subform. But when cloning a form which contains a subform, it didn't work. I encountered errors because it was trying to insert values of the subform also. I saw here how to set all subform values to null: https://forums.nubuilder.cloud/viewtopic. ... ilit=clone

So I added this code:

Code: Select all

if (nuFormType() == 'edit') {
        if (nuIsClone()) {
            $("Input[id^='subgridname']").val('').change();
        }
}
So now the clone works for forms with subforms, but still it inserts values from subform. Example, I'm trying to clone a company form which displays in a subform the employees of this company:

Before clone:
Capture d’écran 2018-05-31 à 14.44.59.png
After clone:
Capture d’écran 2018-05-31 à 14.45.18.png
As you can see, it added the old contact of the old company to the new cloned company (it created a new contact with the CONCAT used on the subform for display purpose)
Capture d’écran 2018-05-31 à 14.45.29.png
And here are the errors I have in debug:

Code: Select all

[0] : 
===USER==========

globeadmin

===PDO MESSAGE=== 

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'contact_entreprise_id' in 'field list'

===SQL=========== 

INSERT INTO relance         (relance_id, `contact_entreprise_id`, `relance_date`, `relance_type`, `relance_info`, `relance_statut`)  VALUES ('5b0fef45b61b749', '5b0fef45b598dc2', '2018-05-31', 'Téléphone', 'TESTRELANCE', 'A faire');

===BACK TRACE====

/var/www/erpversus/nudata.php - line 346 (nuRunQuery)

/var/www/erpversus/nuapi.php - line 50 (nuUpdateDatabase)

Code: Select all

[0] : 
===USER==========

globeadmin

===PDO MESSAGE=== 

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'contact_entreprise_id' in 'field list'

===SQL=========== 

INSERT INTO relance         (relance_id, `contact_entreprise_id`, `relance_date`, `relance_type`, `relance_info`, `relance_statut`)  VALUES ('5b0fef45b5e7abb', '5b0fef45b598dc2', '2018-06-01', 'Email', 'TEST', 'A faire');

===BACK TRACE====

/var/www/erpversus/nudata.php - line 346 (nuRunQuery)

/var/www/erpversus/nuapi.php - line 50 (nuUpdateDatabase)

So how can I avoid any subform rows from cloning as well ?

Re: Clone not working

Posted: Thu May 31, 2018 3:49 pm
by toms
I think we have no control over this. This is how nuBuilder's cloning function works.

Re: Clone not working

Posted: Thu May 31, 2018 4:39 pm
by toms
The manual way is to do the cloning yourself with PHP/SQL:
https://stackoverflow.com/questions/116 ... unique-key

Re: Clone not working

Posted: Sat Jun 02, 2018 2:00 am
by admin
.