Page History
...
Users who wish to keep things simple are invited to use access methods as explained with the next chapter Accessing Arguments. Subsequent chapters are aimed at users with a high load of possibly hundreds of arguments who required require detailed information about the source of arguments.
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
class JobArguments { // arguments with string data type colorBlue = new js7.JobArgument('color_blue', true, 'blue'); colorRed = new js7.JobArgument('color_red', true, 'red'); colorOrange = new js7.JobArgument('color_orange', true, 'orange'); // arguments with numeric data type numOfDays = new js7.JobArgument('num_of_days', true, 5); // arguments with Boolean data type isEndOfMonth = new js7.JobArgument('is_end_of_month', true, true); // arguments with masked output that prevents values from being logged password = new js7.JobArgument('password', true, 'secret', js7.DisplayMode.MASKED); } class JS7Job extends js7.Job { declaredArguments = new JobArguments(); processOrder(js7Step) { // get list of all declared arguments var args = js7Step.getAllDeclaredArguments(); js7Step.getLogger().info('[getAllDeclaredArguments]:'); js7Step.getLogger().info('all declared arguments: ' + args); for (var arg in args) { js7Step.getLogger().info('declared argument: ' + args[arg].getName() + '=' + args[arg].getValue()); } } } |
Explanation:
- The example declares a number of arguments with default values in different data types.
- The
getAllDeclaredArguments()
method returns the list of arguments that can be iterated.
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
class JS7Job extends js7.Job { processOrder(js7Step) { // access argument //by getname list of Job Resource arguments var args = js7Step.getJobResourcesArgumentsAsNameDetailValueMap(); js7Step.getLogger().info('[getJobResourcesArgumentsAsNameDetailValueMap] by name:'); js7Step.getLogger().info('arguments: ' + args); var colorBlue for (var arg in args) { = js7Step.getJobResourcesArgumentsAsNameDetailValueMap()['color_blue']; js7Step.getLogger().info('argument: ' + arg + ' color_blue=' + args[arg]colorBlue.getValue()); } } } |
Further Resources
...
Overview
Content Tools