Hello!
Here is some code that will schedule a workflow with the specified ID. In this case, it's just passing in one parameter, hostname. It's scheduling the workflow according to the "date" parameter.
My question is, is there a way to pass in a schedule description? Or even a name? In the screenshot below, I manually updated the schedule description to contain "test", but I'd like to pass in a description (or name) in an automated fashion. I appreciate any help!
var workflowToLaunch = Server.getWorkflowWithId("41392622-b385-4124-9b9b-15a99ddb794c");
if (workflowToLaunch == null) {
throw "Workflow not found";
}
var workflowParameters = new Properties();
workflowParameters.put("hostname",hostname);
var scheduledTask = workflowToLaunch.schedule(workflowParameters,date);
Hi,
You can use special parameters named __taskName and __taskDescription
// ...
workflowParameters.put("__taskName", "custom task name");
workflowParameters.put("__taskDescription", "custom task description");
var scheduledTask = workflowToLaunch.schedule(workflowParameters,date);
LukasWe - vRO scheduled workflows are not vCenter tasks.
Hi,
maybe this helps:
var scheduledTaskManager = VcPlugin.allSdkConnections[0].scheduledTaskManager;
var scheduler = new VcDailyTaskScheduler(); // use this for a daily schedule only
scheduler.interval = 1;
scheduler.hour = 9;
scheduler.minute = 41;var taskSpec = new VcScheduledTaskSpec();
taskSpec.name = "My task name";
taskSpec.description = "My task description";
taskSpec.enabled = true;
taskSpec.scheduler = scheduler;
// ... use scheduledTaskManager to create your task
Hi,
You can use special parameters named __taskName and __taskDescription
// ...
workflowParameters.put("__taskName", "custom task name");
workflowParameters.put("__taskDescription", "custom task description");
var scheduledTask = workflowToLaunch.schedule(workflowParameters,date);
LukasWe - vRO scheduled workflows are not vCenter tasks.
That worked perfectly Ilian! I was hoping it would be simple. Thank you!
Thanks for the clarification iiliev