10-17-2013 06:18 PM
I have a metadata called "total" on a document. This document can have a variable number of children documents, all having a metadata called "amount".
How can I parameter an automation chain to calculate the "total" from the parent document which must be equal to the sum of the "amount" of its children documents ?
Thanks for your help !
10-18-2013 04:38 AM
It seems to me the best bet is to implement somekind of event handler, listening change event on child document. Then child document get its parent to recalculate the total.
10-18-2013 06:11 AM
Thanks for your reply
10-19-2013 04:02 AM
I can think of mainly three ways to do this, but none I know exactly how to implement, because I myself is very green in Nuxeo development and am trying to figure out how to do simple things.
10-18-2013 10:08 AM
not the solution, but it can helps :
I did a groovy script for Nuxeo Shell, similar to your needs Hope it can inspire you
import org.nuxeo.ecm.core.api.IdRef;
import org.nuxeo.ecm.core.api.PathRef;
def ref = Context["ref"];
def docRoot = null;
if (ref == null || ref == "") { return "Context execution variable not set : ref"; }
try {
if (ref.startsWith("/")) {
docRoot = Session.getDocument(new PathRef(ref));
} else {
docRoot = Session.getDocument(new IdRef(ref));
}
} catch (Exception e) {
return "Exception: ${e.getMessage()}.";
}
def docRootAndChildren = [];
docRootAndChildren = Session.query("SELECT * FROM Folder WHERE ecm:path STARTSWITH '${docRoot.getPath()}'");
def total = 0;
for (doc in docRootAndChildren) {
total += Integer.parseInt(doc.getProperty("dublincore", "source"));
}
return "total = ${total}";
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.