0

Prefill Field when creating new record

Is there way that makes the new record when open, prefill certain fields based on what is coded in the button.

for example.

I would like to book a guest into a tour.

i currently have the table composed into the main table and the staff clicking on "create record" . i would like it so that the staff press a button that will have it preset that when it is clicked, not only will it open a new record to add to the guests table, but also to prefill the date to match the main tables date (if that makes sense)

my current code is :

let newRec := (create 'Segway Guests');
popupRecord(newRec);
Guests.'Date of Tour' = Date

this works well to create the new record, but involves the staff having to put in the correct date, correct tour etc.

I am trying to minimise user error and have it so when the button is clicked, the date is pre filled to match the from and session time is match.

Tour info form: Note the book guest button

Date i would like to have prefilled

Form that books the guest and fields that i would like to prefill

3replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
    • Fred
    • Fred
    • 6 mths ago
    • Reported - view

    Your code is almost there:

    let t := this;
    let newRec := (create 'Segway Guests');
    newRec.(Guests.'Date of Tour' = t.Date)
    popupRecord(newRec);
    

    First you have to collect the data from the current record, line 1. Then you put the changes you want to make in the new record right after creating it. Then you have to tell Ninox what to change and from where to get the data (using the newRec and t variables). Then you can open the new record.

    Like
  • As presumably by definition all guests on the same tour have to go on the same date, if your Guests table is linked to the Tours table then you don't need another date.  Just reference the Tours date as a formula in the Guests table.  That way, if ever the tour date/time should change at the last minute (does that ever happen?) you only have to make one change to the Tour date/time and not to all the Guest records as well.

    Like
    • Admin
    • Admin.11
    • 6 mths ago
    • Reported - view

    Thanks for all the advice,

    i actually ended up with this code:

    let newRecord := (create 'Segway Guests');
    let Date := Date; (The second date refers to a field in the main table that i want the information for)
    let tourtype := 'Session 1 Tour Type';
    newRecord.('Tour Date' := Date);
    newRecord.(Session := 1);
    newRecord.('Tour Type' := tourtype);
    popupRecord(newRecord)

    Like
Like Follow
  • 6 mths agoLast active
  • 3Replies
  • 60Views
  • 3 Following