Page 1 of 1
Prevent Orphan Records
Posted: 2022-03-17 15:44
by rpierce
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
Re: Prevent Orphan Records
Posted: 2022-03-17 16:32
by jsetzer
Did you check the [X] Required flag on all lookup fields?
Re: Prevent Orphan Records
Posted: 2022-03-17 17:24
by rpierce
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?
Re: Prevent Orphan Records
Posted: 2022-03-17 18:05
by jsetzer
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.
Re: Prevent Orphan Records
Posted: 2022-03-17 20:30
by rpierce
I have left the data types as defined by AppGIni: Integer, Unsigned, But I have them set to hide and some are auto fill.
Re: Prevent Orphan Records
Posted: 2022-03-17 20:36
by rpierce
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.
Re: Prevent Orphan Records
Posted: 2022-03-17 21:54
by rpierce
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!
