Adding a field after a db was created

Questions related to using nuBuilder Forte.

Adding a field after a db was created

Unread postby Mike1961 » Sat Aug 21, 2021 4:23 am

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
TT7- DB.jpg (132.85 KiB) Viewed 192 times


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.jpg (29.86 KiB) Viewed 192 times


TT7_task_creator (input-text).jpg
TT7_task_creator (input-text).jpg (98.92 KiB) Viewed 192 times


*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
TT7_task_creator with automatic user_id insertion.jpg (5.84 KiB) Viewed 190 times


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
TT7_task_creator user_id failure (cryptic).jpg (11.73 KiB) Viewed 189 times


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
zzzzsys_user_id.jpg (37.58 KiB) Viewed 189 times


No explanations. Just created another user. Name in NuBuilder is text, Id in zzzz_user_id is numerical

Users (added Simon).jpg
Users (added Simon).jpg (39.74 KiB) Viewed 189 times


zzzzsys_user_id (added Simon).jpg
zzzzsys_user_id (added Simon).jpg (46.89 KiB) Viewed 189 times
Mike1961
 
Posts: 17
Joined: Thu Aug 12, 2021 2:41 am
nuBuilder Version: 4.5

Re: Adding a field after a db was created

Unread postby jut » Thu Sep 16, 2021 2:14 pm

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.
jut
 
Posts: 2
Joined: Thu Sep 16, 2021 10:26 am
nuBuilder Version: 4.5

Re: Adding a field after a db was created

Unread postby kev1n » Thu Sep 16, 2021 2:32 pm

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.
kev1n
nuBuilder Team
 
Posts: 2008
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: Adding a field after a db was created

Unread postby kev1n » Thu Sep 16, 2021 3:15 pm

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.
Attachments
join.jpg
join.jpg (122.47 KiB) Viewed 79 times
kev1n
nuBuilder Team
 
Posts: 2008
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5


Return to General

Who is online

Users browsing this forum: No registered users and 19 guests