0

Button script: add new record from table B to current record in table A

I have linked tables in a somewhat complex database. I have a button that is running a script to create a record and other tasks, but the part that I am stuck on is how to tell Ninox to add the record that was just created in Table B to current record in Table A

let currentVehicle := this.Vehicle;
for i from 12 to 22 do
    let newVehicleService := (create 'Vehicle Service');
    newVehicleService.(
        Vehicle := currentVehicle;
        'Service Type' := i
    );
    let newServiceLog := (create 'Service Log');
    newServiceLog.('Vehicle Service' := newVehicleService);
    let this.'Service Log' := newServiceLog;
    void
end

If I leave 'this' from the beginning it will create a new Service Log, but it will not be linked to the current record. Adding 'this' produces a compile error. I've created a new Vehicle Service and made it part of the new Service Log, but I can't seem to handle adding the new Service Log to the current record.

Reply

null