VMware Cloud Community
dwittenberg2008
Contributor
Contributor

Workflow and script names as variables inside workflow?

So I'm fairly new to writing scripts from scratch and not just hacking others, and I wanted to be able to print some messages in the log for debugging, and thought it would be really handy to just put something like:

System.log("Workflow: " + currentWorkflow);

System.log("Script: " + currentScript);

Is the current workflow and/or script names available as pre-defined variables already?

Thanks!

Dan

Reply
0 Kudos
4 Replies
sbeaver
Leadership
Leadership

I am not sure about calling a variable but why not create a title variable in any workflows and call from there

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**
Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

For workflows, you can use one of these:

System.log("Root workflow name: " + workflow.rootWorkflow.name);

System.log("Current workflow name: " + workflow.currentWorkflow.name);

For scripting actions, try the following (note: this is a bit low-level, implementation-specific code that may change in future versions)

var actionName = arguments.callee.name.substr(6);

System.log("Currently running action: " + this.name + "." + actionName);

Reply
0 Kudos
dwittenberg2008
Contributor
Contributor

I found this is another thread, and since I'm getting errors I wonder if support for it's been dropped?

ReferenceError: "arguments" is not defined.

That's the error I get when I tried to use it.

Dan

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

I did a quick test in my environment; seems to work fine.

Which vRO version do you use?

Also, are you sure you put the action name logging code inside an action element? If you put them inside eg. scriptable task element, you'll get reference errors.

Reply
0 Kudos