Prevent Orphan Records

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
rpierce
Veteran Member
Posts: 255
Joined: 2018-11-26 13:55
Location: Washington State

Prevent Orphan Records

Post by rpierce » 2022-03-17 15:44

Hi all,

I am looking for a method of preventing a record being created in a Child table if there is no corresponding Parent record.

This is an app for developing a Job Hazard Analysis document for construction projects. The parent table is "Project" the child to that is "Tasks" and the child to that is "Hazard". I want to prevent any records from being created in either "Tasks" or "Hazard" if there is no "Project" (project.project_id) existing first.

Thank you for any help!

Ray

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Prevent Orphan Records

Post by jsetzer » 2022-03-17 16:32

Did you check the [X] Required flag on all lookup fields?
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

rpierce
Veteran Member
Posts: 255
Joined: 2018-11-26 13:55
Location: Washington State

Re: Prevent Orphan Records

Post by rpierce » 2022-03-17 17:24

For some reason, whenever I check the parent_id field as required, AppGini unchecks them. Is there some reason that these fields cannot be marked as Required?

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Prevent Orphan Records

Post by jsetzer » 2022-03-17 18:05

Lookups can definitely be required. I'm doing so almost every day.

Did you change any other properties of the lookup field like datatype?

Just adding a field CTRL+F and setting the 2 most important lookup settings (table+caption) without touching any other properties does just fine. Then you should be able to check [X] Required flag.

I have never experienced problems with required lookup fields.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

rpierce
Veteran Member
Posts: 255
Joined: 2018-11-26 13:55
Location: Washington State

Re: Prevent Orphan Records

Post by rpierce » 2022-03-17 20:30

I have left the data types as defined by AppGIni: Integer, Unsigned, But I have them set to hide and some are auto fill.

rpierce
Veteran Member
Posts: 255
Joined: 2018-11-26 13:55
Location: Washington State

Re: Prevent Orphan Records

Post by rpierce » 2022-03-17 20:36

It's odd, I check the "Required" box for one of the parent fields and if I click on another field and then back to the parent field it is unchecked. If I check the "required" box and generate the app the requirement does not take place in the app and the box is then unchecked.

rpierce
Veteran Member
Posts: 255
Joined: 2018-11-26 13:55
Location: Washington State

Re: Prevent Orphan Records

Post by rpierce » 2022-03-17 21:54

I am so dumb sometimes!! I read through the documentation online and found that if a lookup field is marked as "Read Only" the "Required" parameter will be ignored. Sorry to create a useless post! :(

Post Reply