VMware Cloud Community
just70
Contributor
Contributor
Jump to solution

How do I add a description to scheduled workflow?

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);

pastedImage_2.png

Tags (1)
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

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.

View solution in original post

4 Replies
LukasWe
Enthusiast
Enthusiast
Jump to solution

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

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

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.

just70
Contributor
Contributor
Jump to solution

That worked perfectly Ilian! I was hoping it would be simple. Thank you!

Reply
0 Kudos
LukasWe
Enthusiast
Enthusiast
Jump to solution

Thanks for the clarification iiliev

Reply
0 Kudos