Hi,
Let's say you want to restart a workflow called "aaa". Please use the code below to do so. You can play with "b.state" to decide what the state of the workflow you want to restart should be before you restart it. The available states are: "completed", "running”, or "failed". The "b.getInputParameters()" will make sure the same inputs will be reused. If needed, you can add "b.getAttributes()" to reuse the attributes as well.
var bb = Server.findAllForType("WorkflowToken")
for each (b in bb) {
if (b.currentWorkflow.name === "aaa" && b.state != "running") {
b.currentWorkflow.execute(b.getInputParameters())
}
}