Since the unclear and lack of documentation of some API method.
I would rather ask for a helping hand in here.
Calling insertAPIEntry simply returns an APIEntry object where you can call save() to save it to the database as a new record.
Currently db.entryCopier() only returns a message of success or not. You should be able to call response.getRootNodeId() to retrieve the entryRootNodeId.
I spent some time tinkering and this is what I found:
db.entryCopier() is an all-in-one version of insertAPIEntry(). But you cannot return the node id or any data from. But InsertAPIEntry() can. Here is a bit of code I wrote that copies information from the current entry, creates a new entry with that data, and then returns the new entry’s ID, and automatically links the current entry to the new entry in a link field I created.
function test(CurrentID){
var query = db.getAPIQuery("/backend2/3");
var entryCurrent = query.getAPIEntry(CurrentID);
var Field1 = entryC.getFieldValue(1000435);
var Field2 = entryC.getFieldValue(1000436);
var entryNew = query.insertAPIEntry();
entryNew.setFieldValue(1000435, Field1);
entryNew.save();
var NewID = entryNew.getRootNodeId();
entryNew = query.getAPIEntry(NewID);
var LinkFieldID = entryNew.getFieldValue(1000439);
entryCurrent.setFieldValue(1000440, LinkFieldID);
entryCurrent.save();
}
1 Like
Nice Justin