VMware Cloud Community
Hazenet
Enthusiast
Enthusiast
Jump to solution

Module.actions not working

Basic workflow, with just one input/attribute, named "theModule" of type "Module".

Selecting any random Module

A scriptable task, with just 2 simple lines of code:

System.log(theModule.actions)

System.log(theModule.actions.lenght)

Line1 will output "undefined"

Line2 will throw a error: "Cannot read property "length" from undefined"

I have personally tested this on both vRO v7.0.1 and vRO v7.1.

I have also confirmation from other people testing this on vRO v7.0.1 and vRO v7.2

Anyway to get this to work?

Or is this a actual bug, that seems to have been in the software for at least the last 3 versions?

vRO API Browser - Module Actions.jpg

Tags (3)
Reply
0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

Try these lines of code instead:

System.log(theModule.actionDescriptions);

System.log(theModule.actionDescriptions.length);

View solution in original post

Reply
0 Kudos
4 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

Try these lines of code instead:

System.log(theModule.actionDescriptions);

System.log(theModule.actionDescriptions.length);

Reply
0 Kudos
Hazenet
Enthusiast
Enthusiast
Jump to solution

Thanks Ilian

That works, even though its "undocumented".

What is the "best/correct" way to execute a Action found this way?

And yes, I know this is not the normal way to execute actions, but this is a somewhat different/special scenario.

Would it be something like this:

var methodCall = "System.getModule(\"" + theModule.name + "\")." + theModule.actionDescriptions[0].name + "(" + parameter1 + ", " + parameter2 + ")";

actionResult = eval( methodCall );

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

I would prefer the following alternative without eval():

actionResult = theModule[theModule.actionDescriptions[0].name](parameter1, parameter2);

In general, usage of eval() should be avoided if possible, for various reasons (including performance and security risks).

Reply
0 Kudos
Hazenet
Enthusiast
Enthusiast
Jump to solution

Thanks Ilian

I figured that out, with the help of some other vExperts, in the vExpert Slack.

But good to have it confirmed here.

Reply
0 Kudos