// Check if a vRO workflow has running/waiting executions // // For vRO 7.0+ // // Action Inputs: // targetWorkflow - Workflow - Workflow to check running status // // Return type: boolean var lockName = "RunningWorkfowCheck"; var lockId = "vco"; try { System.log("Lock and check if workflow '"+targetWorkflow.name+"' is running..."); LockingSystem.lockAndWait(lockName, lockId); var wfTokens = targetWorkflow.executions; var runningCount = 0; for each (var wfToken in wfTokens) { var state = wfToken.state.toLowerCase(); if ((state != "running") && (state != "completed") && (state != "failed") && (state != "waiting") && (state != "canceled")) { System.error("Unknown workflow state '" + wfToken.state + "'"); } if ((state == "running") || (state == "waiting")) { runningCount++; if (runningCount > 1) { System.log("Workflow '"+targetWorkflow.name+"' is already running."); return true; } } } System.log("No running workflow executions found for '"+targetWorkflow.name+"'."); } catch (e) { System.log("Unlock workflow running check."); LockingSystem.unlock(lockName, lockId); throw e; } finally { System.log("Unlock workflow running check."); LockingSystem.unlock(lockName, lockId); } return false;