0

Auto populate fields with the value from the previous record?

Hi I'm only new to Ninox and setting a database to suit our business.  Is it possible to auto populate fields with the value from the previous record?  This was a very handy feature in Filemaker.

When doing lots of data entry, this would be very helpful and speed up out workflow.  Having it as a selectable option for the field settings would be awesome.

 

Thanks

Ben

5replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Hi Ben

    You can duplicate a record, either by the user interface with the "duplicate" button (which is between the bin and the plus button), or by the code with function duplicate(this) (cf : https://ninox.com/en/manual/calculations/reference-of-functions-and-language)

    Like
  • There is a very good video on youtube from Nioxus

    That deals with chaining info/link from prev records

    Worth a watch but is quite advanced

    link is https://www.youtube.com/watch?v=eaAHmt5hy90

     

    You could as Jaques suggest also us the duplicate command and use together with other commands to get what you want

     

    As an example only

    I have a table called Jobdockets and on the form I have a button to copy the job but don’t want some info to show ( I want to clear it)

    So that users can fill in the new elements

     

    So basically (looking at the last record or any record for that fact)

    Look for the last highest Jobnumber store this into a temp variable xNum)

    Also store the current job number into a temp xJob.  to use as a prev ref

    I want to copy the job to a new record (duplicate(this) line!)

    Open that new job

    Add the next job number to that new job

    Copy old prev jobnumber into a field called prev ref

    Clear the customer order number

    Reset the job status back to NewJob

    Get rid of any sub tables that was connected to that prev job (ie delivery notes etc)

    Change the job date to today

    With that done the user can go onto fill in any other info etc

     

    Here is that script (I’ve cut it down and got rid of everything that is not relevant to above)

    let xNum := max((select JobDockets).'Job Bag');
    let xJob := 'Job Bag';
    let newRecord := duplicate(this);
    openRecord(newRecord);
    newRecord.('Job Bag' := xNum + 1);
    newRecord.(Status := "NewJob");
    newRecord.('Order Ref' := null);
    newRecord.('Prev Ref' := xJob);
    delete newRecord.DeliveryNotes;
    newRecord.('Order Date' := today())

     

    should be self explanatory

    this script goes inside a button on that form.

    As stated I use this on the last or any record that I want to copy to a new job

     

    If you always want the last record - You could also explore to see if yu could look for that last record

    by putting a script into the trigger on create at the table level.

    Ie find the id or highest/last invoice/job number

    Then copy the fields you just want information from into temp variables and

    Post then onto the current newly opened form

    I do this to drive the next quote number

    let before := max((select Quotes).QteNum);
    QteNum := before + 1

    But you could expand on this...

     

    Mel

    Like 1
    • Admin
    • Admin.11
    • 3 mths ago
    • Reported - view

    Hi Mel, 

    just read your code.

    im particularly interested in the date part.

    is it possible for the new records to have the next day example

    precious record was the 1st of January, the new record will automatically have 2nd January.

    newRecord.('Order Date' := today())

    Could I simply change “ today” to “tomorrow”?

    Like
      • Fred
      • Fred
      • 3 mths ago
      • Reported - view

      Admin Sadly "tomorrow" is not an option. You can do:

      newRecord.('Order Date' := today()+1
      
      Like 1
  • As Fred said - Tomorrow never comes !!

    But there is always a work around !! as he has clearly stated

    Like 1
Like Follow
  • 3 mths agoLast active
  • 5Replies
  • 701Views
  • 3 Following