VMware Cloud Community
LaxmiRagi
Enthusiast
Enthusiast

Get Parameters/Attributes list of an Action in VRO.

Hi,

I have a scenario like need to get parameters/attribute list of an action.

For example:  getUser action with 3 parameters like this getUser(param1,param2,param3);

is it possible to get all parameters of get User action?

I have tried with System.getContect();//But Not giving any result.

Please help me to find good way to get all params list.

Thank you in advance.!!!!

0 Kudos
3 Replies
iiliev
VMware Employee
VMware Employee

Hi,

From within the action, you can retrieve its name and arguments with code like the following:

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

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

System.log("number of arguments: " + arguments.length);

for each (var arg in arguments) {

  System.log("argument: " + arg);

}

0 Kudos
LaxmiRagi
Enthusiast
Enthusiast

Thank you Ilian Iliev, its working but i need some more details like name of the argument  also.

is it possible?

0 Kudos
iiliev
VMware Employee
VMware Employee

Arguments' names can be retrieved with code like the following (found this code snippet online):

var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;

var ARGUMENT_NAMES = /([^\s,]+)/g;

function getParamNames(func) {

  var fnStr = func.toString().replace(STRIP_COMMENTS, '');

  var result = fnStr.slice(fnStr.indexOf('(')+1, fnStr.indexOf(')')).match(ARGUMENT_NAMES);

  if(result === null)

     result = [];

  return result;

}

System.log(getParamNames(arguments.callee));

0 Kudos