How to create a new doc within a javascript function in OrientDB
<p>I would like to create a new Document within a javascript function which is triggered when an doc is updated, and is triggered before update.</p>

<p>The new Document is based in the document that I am trying to update.</p>

<p>My function is something like that:</p>

<pre><code>var formattedDate = getDateUTC();
print(formattedDate);
var db = orient.getDatabase();
var newDocument = new com.orientechnologies.orient.core.record.impl.ODocument("Item_Process");
newDocument = doc;
newDocument.field("final_date").value = formattedDate;
newDocument.save();
db.commit();
</code></pre>

<p>The object to update is updated, but a new document is not created.
There is not any error.</p>

<p>Many thanks in advance</p>