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.!!!!
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);
}
Thank you Ilian Iliev, its working but i need some more details like name of the argument also.
is it possible?
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));