You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
varlib={foo: function(node){logger.debug(""+node.name);}};varsql="select 'workspace://SpacesStore/af9f95ac-dfdd-4787-b044-22e2026c4e74'";// some existing NodeRefvarresult=database.query("dataSource",sql);varnodesToMigrate=[];foreach(varrowinresult){varnode=search.findNode(row[0]);if(!node||!node.exists()){continue;}nodesToMigrate.push(node);}varprocess=functionprocess(node){logger.info("processing "+node.typeShort+" "+node.nodeRef);// calling function from `lib` fails!lib.foo(node);};varbeforeProcessFunction=functionbeforeProcess(){};varafterProcessFunction=functionafterProcess(){};batch.runForNodes('Process-',2,10,nodesToMigrate,process,true,beforeProcessFunction,afterProcessFunction);
Observed Behaviour
This will throw
Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "lib" is not defined. (AlfrescoJS#4)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3687)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3665)
at org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3750)
at org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1728)
at org.mozilla.javascript.gen.AlfrescoJS_108._c_process_1(AlfrescoJS:4)
at org.mozilla.javascript.gen.AlfrescoJS_108.call(AlfrescoJS)
at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:63)
at org.mozilla.javascript.gen.AlfrescoJS_108._c_script_0(AlfrescoJS:7)
at org.mozilla.javascript.gen.AlfrescoJS_108.call(AlfrescoJS)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
at org.mozilla.javascript.gen.AlfrescoJS_108.call(AlfrescoJS)
at org.mozilla.javascript.gen.AlfrescoJS_108.exec(AlfrescoJS)
at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:502)
... 29 more
Expected Behaviour
The lib.foo function is executed.
The text was updated successfully, but these errors were encountered:
Consider this code:
Observed Behaviour
This will throw
Expected Behaviour
The
lib.foo
function is executed.The text was updated successfully, but these errors were encountered: