0

Duplicate a record and killing related records etc.(oh and jumping to that new record)

Using Ninox“s build in duplicate a record is great but it does a complete clone of the original record... Which often is fine but...

it does not re trigger say a sequence number field and of course any related records are also copied

So its often preferable to do this by a script on a button and go on to modify the data you want amending or deleting etc.

let d := duplicate(this);
”Order date“ := today() etc.

delete PurchaseOrders (this is the related table)

This seems to copy (duplicate) the record but still leaves you in the original record. Weher as I would rther open that new created record (which i do not know the id of yet?)

and the delete PurchaseOrders gets rid of the related records in your current record not the copied record so again not ideal

Looking at it the other way. Staying the current records to post(write) new enetries ibto a new record. gives me that same issue as I”m still in the original records n

and i don“t know the syntx to say keep a particular relationship ie ”Customers“

let xCurrRelashion ship = ??
let xNewSupplier := Supplier;
let xNewPCost := ”Print Cost“;
let i := (create JobBagCosts);
i.(Supplier := xNewSupplier);
i.(PrintCost := xNewPCost);

Ideally I want to copy (or Write) to a new record and open that record to further edit.

anyone doing this ?

7 replies

null
    • Mel_Charles
    • 3 yrs ago
    • Reported - view

    It it interesting that when I duplicate a record using Ninox interal copy (double folder icon), the focus moves onto that new record

    Ie im in ID23 i press the icon for duplicate and then i“m in say ID410 (which is great cos its in that new copy I want to further edit!

    However doing the same from script ie Duplicate (this) leaves me in ID23.

    • Mel_Charles
    • 3 yrs ago
    • Reported - view

    Oops pressed “post” before i intended to :-)

    So if i wanted to keep my internal ID intact this gives me a problem.

    let us say the following applies

    ID23 record 01/01/20

    ID24 01/02/20

    ID25 07/03/20

    Now sum I duplicate by script ID24 this creates a new record ID26 but leaves me in the orginal ID for the script to continue further editing selected fields.
    okay no real bit issue as a clone has been created in ID26 but ID24 now has todates date and details (maybe a current invoice number etc) and although i can resort the table view etc it means the ID list is out of whack! (unless its possible to re trigger all the Internal ID“s to resort (could this be dangerous)?

    So how can i start a script of in one record - then duplicate that record and continue a script in the newID record.

    I know the obvious thing is to say let my team simple press the NINOX Duplicat record icon and then press a button in that new form to reset any fields/dates sequenced numbers/get rid of linked child tables etc....... But it feels some what inelegent to do this.....

    and i like a challenage - also if NINOX is doing this and jumping to that new record! then that tells me there must be a way to do it by script

    • Alain_Fontaine
    • 3 yrs ago
    • Reported - view

    let newRecord := duplicate(this);

    openRecord(newRecord)

    • Mel_Charles
    • 3 yrs ago
    • Reported - view

    Alain that great thanks.... that part works a treat!!!!

    Whilst it does work - any script instruction below your solution seems to be ignored once you are in the new record!

    so i“m guessing the the script simply terminates when you make to leap! 

    Ideally whan i”m looking to do is invoke the copy then imeadiately go one to process editing out non essiential info from the original record that is not require and also rest the date to today etc. all one that one script....

    Thus you are starting the script running in the old record

    make the leap to the new record and then carry on with running the rest of the script!

    my old software allowed you to daisy chain scripts

    i“m still find out what Niniox can or can”t do

    Ie coukld such a script be run globaly to do this in some way?

    • Alain_Fontaine
    • 3 yrs ago
    • Reported - view

    After the “duplicate” command, you can address the fields of the new record with the notation:

    newRecord.field1 := ....

    newRecord.field2 := ...

    The openRecord command opens the specified record, but DOES NOT update the context of the script, so all the instructions following it are indeed executed, but in the context of the old record. 

    • Mel_Charles
    • 3 yrs ago
    • Reported - view

    ah ha Alain that makes makes sense.!

    Yes on looki ng back I see the script after the open new record had infact modified the exisiting record

    Brilliant will give it a go.

    • Mel_Charles
    • 3 yrs ago
    • Reported - view

    Hi Alain - Works a treat !!!

    Good man :-)

    Mel

Content aside

  • 3 yrs agoLast active
  • 7Replies
  • 845Views