Page 1 of 1

Adding a field after a db was created

Posted: Fri Aug 20, 2021 8:53 pm
by Mike1961
I built my db with several fields and created fast forms (browse and create/edit). All was ok

I tried to create another field (TT7_task_creator) into that dabase and didn't want to recreate one from scratch. The reason ? I want to add on the fly, hidden or not editable, a field with the name of the creator of the task (I'll insert automatically the name of the task creator later)
TT7- DB.jpg
I edited the properties of the browse and edit forms to reflect this addition. However, even the field seems properly inserted in the forms, When I browse or create a new task, the field is always empty. It appears only if I manage the db itself with phpmyadmin.
TT7_task_creator.jpg
TT7_task_creator (input-text).jpg
*EDIT*
It seems that adding a field directly into the db (phpmyadmin) is not necessary. the datatype was missing on the form (even created with phpmyadmin) and obtain an error (Nudebugresult). I "rebuilt" then the form and had no more errors and I'm able now to add the creator into the db.

just (in)validate the way I did before...

*EDIT II*

I suppose I need to add php code in the Before Save (add mode) to inject the name of the logged user into the TT7_tast_creator and make this field readonly. Like this ?

https://github.com/nuBuilder/nuBuilder- ... ve_user_id

Yep, it works ! ;-)
TT7_task_creator with automatic user_id insertion.jpg
Hmmm, it doesn't :-(

When I change the user name and choose somebody else (from my user list), the name is displayed as numbers and not the user name...
TT7_task_creator user_id failure (cryptic).jpg
When I check the zzzz_user_id, I (the admin) am displayed with a name, the users I created are just plain numbers. Will check on my side again to see why.
zzzzsys_user_id.jpg
No explanations. Just created another user. Name in NuBuilder is text, Id in zzzz_user_id is numerical
Users (added Simon).jpg
zzzzsys_user_id (added Simon).jpg

Re: Adding a field after a db was created

Posted: Thu Sep 16, 2021 6:44 am
by jut
I also have this same issue and like you I tried to manually force the database columns into existence.
I tried running the upgrade feature which worked once or twice but this is still a huge problem for me, if you figure it out definitely let me know.

Re: Adding a field after a db was created

Posted: Thu Sep 16, 2021 7:02 am
by kev1n
The foreign key is stored in the table. Use a join to retrieve the related columns from the other tables.

Google for database normalisation, joins.

Re: Adding a field after a db was created

Posted: Thu Sep 16, 2021 7:45 am
by kev1n
As an example, see the user form's browse SQL where sus_zzzzsys_access_id contains the foreign key of the table zzzzsys_access.
A join is used to retrieve sal_code and sal_description from that table.