Hi guys, I am fairly new to Apex and I have trouble trying to solve this case. Hopefully someone can help me here!
The simplified case is as follows: let's say I have a checklist to verify if a house is in good condition or not. Something like this:
House Inspection #99
| Criteria | Result | Comment |
| The water is in good quality | Satisfactory | No broken pipe found inside the house, water is not contaminated |
| The lighting is fine | Unsatisfactory | Only one window available in the living room |
| The wall is sturdy | Satisfactory | No hole in any wall |
There will be many more criteria coming - let's say there will be hundreds of criteria. So I plan to separate the criteria to another table in my database:
Table 1: Criteria List
| ID | Criteria |
| 1 | The water is in good quality |
| 2 | The lighting is fine |
Table 2: House Inspection
| ID | Inspection_ID | Criteria_ID | Result | Comment |
| 1 | 99 | 1 | Satisfactory | No broken pipe found inside the house, water is not contaminated |
| 2 | 99 | 2 | Unsatisfactory | Only one window available in the living room |
| 3 | 101 | 1 | Unsatisfactory | Broken pipe found |
So there are actually two questions here:
- How can I make Apex to automatically generate the form fields for each criteria listed in Table 1?
- How to save the multiple records into Table 2? Here is the mockup form which I want to generate in Apex:

Any help will be appreciated! Thanks in advance!
P.S. I am using Apex v5.0