VMware Cloud Community
GarTomlon
Enthusiast
Enthusiast
Jump to solution

Decision element based on output

I have created a simple workflow that merges both the Checks for File on Guest  and Deletes File on Guest canned workflow.  I am inserting a decision element that I would liek to take the OUTPUT (exists boolean out-param) from the Set Result scriptable task within (from the Check for File on Guest) and bind it to the input of my decision.  Essentially, if the exist parameter is true, it will excute the script to delete the file.  However, I can not figure out how to bind the input of the decision to the output of SetResult.  I am including a snippet showing the desired workflow.  Also below is the script of SetResult that shows the exists out-param.

exists = false;

for (var i in result) {

     var f = result[i];

     System.log(">" + f.path + "<");

     System.log(">" + path + "<");

     System.log(f.path + " : " + f.type + " p:" + (f.path == path) + " f:" + (f.type == "file"));

     if (f.path == path && f.type == "file") {

          exists = true;

          break;

     }

}

output.JPG

script.JPG

0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

You need to ensure that exists variable is mapped as a workflow attribute, not as workflow output when you setup/promote the bindings from 'Check for file in guest' workflow. Then, in your decision element, you will be able to bind the attribute directly.

On the other hand, on the shown schema I don't see how exactly you use 'Check for File in Guest' and 'Delete File in Guest' workflows, so I'm not sure if the exists variable you are referring to is the same exists which is output parameter of 'Check for File in Guest' workflow. But in any case, the decision element will allow you to use variables that are either input parameters or attributes, not output parameters.

View solution in original post

0 Kudos
3 Replies
sbeaver
Leadership
Leadership
Jump to solution

I have something like this that runs multiple times a day.  My workflow is actually looking for java dump files and if it finds the file it will delete.  Looking at your picture I see one thing different than mine.  The process error scripting task is what sets the value to false and you need to have the process error scriptable task connect to the decision or really you can get rid of the decision all together and just have the delete file workflow after the process error.  The list path workflow will fail if the file is not found and the process error tasks sets the value to false. 

Hope that helps

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.**
0 Kudos
filosmith
Enthusiast
Enthusiast
Jump to solution

You have to edit your decision and bind it to the exists attribute, then tell it whether you want exists to be true or false.

pastedImage_0.png

0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

You need to ensure that exists variable is mapped as a workflow attribute, not as workflow output when you setup/promote the bindings from 'Check for file in guest' workflow. Then, in your decision element, you will be able to bind the attribute directly.

On the other hand, on the shown schema I don't see how exactly you use 'Check for File in Guest' and 'Delete File in Guest' workflows, so I'm not sure if the exists variable you are referring to is the same exists which is output parameter of 'Check for File in Guest' workflow. But in any case, the decision element will allow you to use variables that are either input parameters or attributes, not output parameters.

0 Kudos