Fetch other form fields with wilcard

Fetch other form fields with wilcard

Hi 

I need to populate a stateles form with a previous stored data or stores the form data if it does not yet exists.

The test I've made that works fine is the following on the stateless form:
(final_form is the form to store data, but not to be used by user)

ON LOAD:
// present on screen the data already stored in db
rec  =  final_form  [number == input.number];
input.a = rec.aa;
input.b = rec.bb;

ON CLICK:
rec  =  final_form  [number == input.number];

if (rec.ID  ==  null)
{
     // if the record does not exists yet, store it
    insert into final_form
    [
        aa = input.aa
        bb = input.bb
        number = input.number
    ]
}
else
// update all record fields from stateless input data 
{
    rec.aa = input.aa;
    rec.bb = input.bb;
}


This works fine, but now I'm preparing to replicate the idea in a real application where the forms have dozens of fields.
If I use this method, it will be very time consuming and the error risk is enourmous. If I add fields in the forms, i must remember to go to every code  of forms to check if no field was forgot which is almost an impossible tasks due to the number of fields.

So my question is is there any way to do this with wildcards, like for example the following. 

ON LOAD:
rec  =  final_form  [number == input.number];
input.* = rec.*;

ON CLICK:
rec  =  final_form  [number == input.number];

if (rec.ID  ==  null)
{
    insert into final_form
    [
        final_form.* = input.*
        number = input.number
    ]
}
else
{
    rec.* = input.*;
    }



If not possible any suggestions to make this easier that code all the fields?

Thanks a lot for your help on this.

My best regards