Hi,
This is my current script trying to emulate the menu > duplicate command and then update a few fields in the duplicate.
However, it only has the fields I explicitly name in script's assignments or that have a default value in the new entry. So it is not a duplicate because 10 other fields were not copied.
Important question: Is there a mechanism in Memento Javascript to do what the Duplicate command does?
I imagine something like, but have no idea obviously:
thislib.createduplicate(nuentry); // magic command to make nuentry an identical DUPLICATE of current entry.
Thanks very much!
// My script
var thislib = lib();
var el = lib().entries();
var e = entry();
var nuentry = new Object();
var x, thisenum;
var linkedEntry = e.field("Name")[0];
x = el[0].field("Entry #") + 1; // make new entry #
nuentry["Entry #"] = x;
nuentry["Activity"] = e.field("Activity").join(); // Convert activities array to string
nuentry["Name"] = linkedEntry;
thislib.create(nuentry); // make the new entry
thisenum = e.field("Entry #");
message("Duplicate of " + thisenum + " created. Entry # " + x);