VMware Cloud Community
pagra
Contributor
Contributor

Getting scriptable task name with javascript from inside the scriptable task

Hi all,

is there a way to get the scriptable task name inside the scriptable task with javascript inside vRA / vRO 7.6?

Something like it exists for receiving the current workflow name or the name of an action.

// get current workflow name

workflow.currentWorkflow.name

// get current action name

arguments.callee.name.substr(6)

Thanks,

Patrick

0 Kudos
1 Reply
eoinbyrne
Expert
Expert

Doesn't look like there's a built-in way to get what you want

In the workflow.currentWorkflow refers to the actual Workflow object

pastedImage_0.png

This object has a list of items which refer to the components (scriptables, actions etc). Each of those have the following structure

pastedImage_1.png

Given that each WorkflowItem has a link to the next item you *may* be able to come up with a way to walk the item tree and then work out which one you're currently in during execution? Not that promising sadly and would probably get very messy if the workflow has lots of branching......

I guess worst case you could just do a System.log("Starting task <task name goes here>") at the top of every scriptable? Again, not ideal but at least gives you the trace you wanted in the scripting.log file. Alternatively, Server.log would give you the trace in the event log for the workflow execution

-HTH

0 Kudos