Hi there,we are using alfresco community edition V.4.0bI wanted to delete all workflow instances (assuming this will delete all tasks as well).So i wrote a webscript:
var wfDefs = workflow.getAllDefinitions();
for (i in wfDefs) {
var wfDef = wfDefs[i]
logger.error("Def:" + wfDef.id);
var wfInsts = wfDef.activeInstances;
for (j in wfInsts) {
wfInst = wfInsts[j];
logger.error(" Inst:" + wfInst.id);
wfInst.cancel();
}
}
that doesnt seem to work:Message: 00240112 Wrapped Exception (with status template): 00242923 Failed to execute script 'classpath*:alfresco/extension/templates/webscripts/hecktests/heckhello.get.js': 00242922 Failed to execute supplied script: 00242921 TypeError: Cannot find function fatal. (AlfrescoJS#2) Exception: org.mozilla.javascript.EcmaError - TypeError: Cannot find function fatal. (AlfrescoJS#2) org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3350) org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3340)Then i tried the same with delete()
var wfDefs = workflow.getAllDefinitions();
for (i in wfDefs) {
var wfDef = wfDefs[i]
logger.error("Def:" + wfDef.id);
var wfInsts = wfDef.activeInstances;
for (j in wfInsts) {
wfInst = wfInsts[j];
logger.error(" Inst:" + wfInst.id);
wfInst.delete();
}
}
This doesnt work because delete is a reserved JavaScript keyword. 00240114 Wrapped Exception (with status template): 00242928 Failed to execute script 'classpath*:alfresco/extension/templates/webscripts/hecktests/heckhello.get.js': missing name after . operator (file:/ext/opt/alfresco-4.0.b/tomcat/shared/classes/alfresco/extension/templates/webscripts/hecktests/heckhello.get.js#514) Exception: org.mozilla.javascript.EvaluatorException - missing name after . operator (file:/ext/opt/alfresco-4.0.b/tomcat/shared/classes/alfresco/extension/templates/webscripts/hecktests/heckhello.get.js#514) org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:109) org.mozilla.javascript.DefaultErrorReporter.error(DefaultErrorReporter.java:96)I think this can be considered basic functionality, so it has to work somehow… i hope.Any help is highly appreciated.ThanksMatthias Heckmann