Tip around Logging for Big Workflows with Scriptable tasks and actions

How to control and measure logs while working with big vRO workflows? Learn how a single line of code can make such a huge difference.


min read

Tip around Logging for Big Workflows with Scriptable tasks and actions


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.


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.


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.

vRO Workflow Screenshot with scriptable tasks | Image by Author

You can also print the item# if you want, using this command



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.

System.log("\"" + System.currentWorkflowItem().getDisplayName() + "\" action started");
System.log("\"" + System.currentWorkflowItem().getDisplayName() + "\" action ended");
A vRO Action | Image by Author
vRO Workflow Screenshot with scriptable tasks and action | Image by Author

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

A vRO Action | Image by Author


How to get some information related to workflow items inside the workflow itself.

System.log("TokenName: "+workflow.currentWorkflow.name); -> Workflow Name
System.log("TokenName: "+workflow.name); -> Token Name
System.log("WorkflowName: "+workflow.rootWorkflow.name); -> Workflow Name
var wfInstance = Server.getWorkflowWithId(workflow.currentWorkflow.id); 
System.log(wfInstance.workflowCategory.path +"/"+wfInstance.name); -> Workflow Path/Workflow Name
System.log("WorkflowObject: "+wfInstance); -> Workflow type object
System.log("WorkflowFirstItem: "+wfInstance.firstitem);
System.log("*** List of items in Workflow");
for (var i = 0; i < wfInstance.items.length; i++)
    System.log(wfInstance.items[i].name); // End, Scriptable Task, Start, Scriptable Task #2
System.log("*** List of attributes in Workflow");
for (var i = 0; i < wfInstance.executions.length; i++){
    if(i == 1){
        for (var i = 0; i < wfInstance.executions[i].attributesStack.length; i++){

Leave a Reply

Related Posts

3 responses to “Tip around Logging for Big Workflows with Scriptable tasks and actions”

  1. Teknik Industri Avatar

    What are some best practices for managing logs in extensive workflows that utilize scriptable tasks?

    1. Mayank Goyal Avatar

      I would say the classic System.log() would do the job. Just afraid them to use as much as want. However, you can also consider the LogMarker class https://cloudblogger.co.in/2023/03/23/vro-logmarker-better-than-logger-action/