cancel
Showing results for 
Search instead for 
Did you mean: 

Error associating an advanced workflow by a custom behavior

mabayona
Champ on-the-rise
Champ on-the-rise
Using 2.9C_dev, when I associate an advanced workflow to a document in the code activated by a custom behavior, I get the following warning in the logs:

RHINO USAGE WARNING: Missed Context.javaToJS() conversion:
Rhino runtime detected object Node Type: {my.model}mycustom_node, Node Aspects: [{http://www.alfresco.org/model/system/1.0}referenceable, {http://www.alfresco.org/model/application/1.0}uifacets, {http://www.alfresco.org/model/content/1.0}auditable] of class org.alfresco.repo.jscript.ScriptNode where it expected String, Number, Boolean or Scriptable instance. Please check your code for missing Context.javaToJS() call.

The custom type is subtype of cm:folder and gets created, but when y try to delete it it reports:

Please correct the errors below then click OK. 
Unable to delete Space due to system error: Failed to execute transaction-level behaviour public abstract void org.alfresco.repo.node.NodeServicePolicies$OnDeleteNodePolicy.onDeleteNode(org.alfresco.service.cmr.repository.ChildAssociationRef,boolean) in transaction d819420f-e451-11dc-8da4-cf9713cd64b2


and it does not get deleted.

The code that raises the first error is:

var scriptFailed = false;
// Have a look at the behaviour object that should have been passed
if (behaviour == null) {
   logger.log("The behaviour object has not been set.");
   scriptFailed = true;
}
// Check the name of the behaviour
if (behaviour.name == null && behaviour.name != "onCreateNode") {
   logger.log("The behaviour name has not been set correctly.");
   scriptFailed = true;
} else {
   logger.log("Behaviour name: " + behaviour.name);
}
// Check the arguments
if (behaviour.args == null) {
   logger.log("The args have not been set.");
   scriptFailed = true;
} else {
   if (behaviour.args.length == 1) {
      var register= behaviour.args[0].child;
      var operation = register.parent.parent;
      
      var pipeline = operation.parent;
      var children = pipeline.children;
      var phase = "";
      
      if (children != null && children.length > 0) {
         for (i in children) {
            var child = children[i];
            if (child.properties.name == "Fase Name") {
               fase_origin= child;
            }
         }
         
         if (fase_origin != "") {
            operation.move(fase_origin);
            logger.log("Operation moved");
         }
      }
      
      operation.save();



        }
}

Any idea why…
1 REPLY 1

mabayona
Champ on-the-rise
Champ on-the-rise
It was an obvious error in the "onDeleteNode" behaviour code (i.e. a deleted node does not exists….).

The RHINO warning persists however. I assume this is a minor implementation error that has nothing to do with my code.