Introduction
It’s quite evident that vRO Workflows can grow huge for major provisioning tasks like hardware deployments, vApp deployments or tenant provisioning etc. just to name a few. And in a big environment, such workflows can come in large numbers and may be coupled with various other workflows quite generally for eg. using Nested WFs.
Concern
Now, the real pain starts when you have to debug them. for Debugging, developers relies mostly on System.log() or System.debug() to know about the statuses and variable values etc. up to a particular point, which is really great.
If I talk about myself, I even uses a start and completion log for every Scriptable task in a workflow. This always pinpoints to the scriptable task that was started but couldn’t complete due to any reason and therefore couldn’t print the end log. Let me explain it. There is a workflow (Create a VM) and there is a scriptable task (Get All VM Names). In this scriptable task, I would add some thing like
System.log("\"Get all VM Names\" script started");
and at the end of this script
System.log("\"Get all VM Names\" script completed");
Imagine this in a very large workflow, this can really help. But I knew this needs to be improved. Sometimes, you changes the content of a scriptable task and its definition changes, so update it’s name -> Get All VM Names to Get All VM Names and IPs. In such cases, you have to update those start and end log statements. And I hate that!
Possible Solution
I referred to the vRO community (link) and found one interesting way out.
FOR WORKFLOWS
We can use this,
System.log("\""+System.currentWorkflowItem().getDisplayName()+"\" script started");
System.log("\""+System.currentWorkflowItem().getDisplayName()+"\" script completed");
This will automatically print the updated name of the scriptable task.

You can also print the item#
if you want, using this command
System.currentWorkflowItem().getName();
FOR ACTIONS (OPTIONAL)
Now, this is a little tricky. We can’t do the same for actions. However, if we consider them as a part of a workflow, which means they will act similarly as an item and obviously will have a item number, then we can print their start and end cycle. We can do so by adding the below mentioned script in your actions.
if(System.currentWorkflowItem().getDisplayName())
System.log("\"" + System.currentWorkflowItem().getDisplayName() + "\" action started");
if(System.currentWorkflowItem().getDisplayName())
System.log("\"" + System.currentWorkflowItem().getDisplayName() + "\" action ended");


Here, we added a condition just to avoid printing if you try to run your actions solely.Ended "" script
