Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Clone not working

Questions related to using nuBuilder Forte.
marcvander
Posts: 101
Joined: Mon Mar 26, 2018 5:57 pm

Re: Clone not working

Unread post 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 ?
You do not have the required permissions to view the files attached to this post.
Config:
nuBuilder v4 on a dedicated LAMP server:
-Ubuntu 14.04.5 LTS
-Apache 2.4.7
-MySQL 14.14 Distrib 5.7.22
-PHP 5.5.9-1ubuntu4.23
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: Clone not working

Unread post by toms »

I think we have no control over this. This is how nuBuilder's cloning function works.
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: Clone not working

Unread post by toms »

The manual way is to do the cloning yourself with PHP/SQL:
https://stackoverflow.com/questions/116 ... unique-key
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Clone not working

Unread post by admin »

.
Post Reply