Page History
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
class JS7Job extends js7.Job { processOrder(js7Step) { var workflowPath = js7Step.getAllArgumentsAsNameValueMap['js7Workflow.path']); // access argument by name js7Step.getLogger().info('[getAllArgumentsAsNameValueMap] by name:'); var colorBlue = js7Step.getAllArgumentsAsNameValueMap()['color_blue']; js7Step.getLogger().info('argument: color_blue=' + workflowPathcolorBlue); } } |
Explanation:
- The
getAllArgumentsAsNameValueMap()
method provides a map of all arguments. The map allows to read a single argument from specifying the argument name. - Argument values are returned in one of the supported data types including string, number and Boolean.
- Consider that argument names are case-sensitive.
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
class JS7Job extends js7.Job { processOrder(js7Step) { // get list of all arguments var args = js7Step.getAllArguments(); js7Step.getLogger().info('[getAllArguments]:'); js7Step.getLogger().info('all arguments: ' + args); for (var arg in args) { js7Step.getLogger().info('argument: ' + arg + '=' + args[arg].getValue()); } } } |
Explanation:
- Consider the literal meaning of "all arguments". The example will return arguments from all sources.
- Argument values are returned in one of the supported data types including string, number and Boolean.
...
- Order Variables have to be specified for any Declared Variables that are not assigned a default value.
- Order Variables can specify Declared Variables holding default values. The Order Variable over-rules overrules the default value.
Download sample workflow implementing access to Order Variables (upload .json): pdJavaScriptOrderVariables.workflow.json
Reading specific Order Variables
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
class JS7Job extends js7.Job { processOrder(js7Step) { var workflowPath = js7Step.getAllArgumentsAsNameValueMap['js7Workflow.path']); // access argument by name js7Step.getLogger().info('[getOrderArgumentsAsNameValueMap] by name:'); var colorBlue = js7Step.getOrderArgumentsAsNameValueMap()['color_blue']; js7Step.getLogger().info('argument: color_blue=' + workflowPathcolorBlue); } } |
Reading the list of Order Variables
To iterate the list of Order Variables the following proceeding applies:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
class JS7Job extends js7.Job {
processOrder(js7Step) {
// get list of order variables
var args = js7Step.getOrderArgumentsAsNameValueMap();
js7Step.getLogger().info('[getOrderArgumentsAsNameValueMap]:');
js7Step.getLogger().info('all arguments: ' + args);
for (var arg in args) {
js7Step.getLogger().info('argument: ' + arg + '=' + args[arg]);
}
}
} |
Accessing Declared Arguments
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
class JobArguments { workflowPathcolorBlue = new js7.JobArgument('js7Workflow.pathcolor_blue', true); } class JS7Job extends js7.Job { declaredArguments = new JobArguments(); processOrder(js7Step) { // option 1: access declared argument // option 1.a: access declared argument by name js7Step.getLogger().info('[GetDeclaredArgument] by name:'); var declaredArg1a = js7Step.getDeclaredArgument('js7Workflow.pathcolor_blue'); js7Step.getLogger().info('declaredArgument: ' + declaredArg1a.getName() + '=' + declaredArg1a.getValue()); // option 1.b: access declared argument by object name js7Step.getLogger().info('[GetDeclaredArgument] by object name:'); var declaredArg1b = js7Step.getDeclaredArgument(this.declaredArguments.workflowPathcolorBlue.name); js7Step.getLogger().info('declaredArgument: ' + declaredArg1b.getName() + '=' + declaredArg1b.getValue()); // option 2: access declared argument value // option 2.a: access declared argument value by name js7Step.getLogger().info('[GetDeclaredArgumentValue] by name:'); js7Step.getLogger().info(js7Step.getDeclaredArgumentValue('js7Workflow.pathcolor_blue')); // option 2.b: access declared argument value by object name js7Step.getLogger().info('[GetDeclaredArgumentValue] by object name:'); js7Step.getLogger().info(js7Step.getDeclaredArgumentValue(this.declaredArguments.workflowPathcolorBlue.name)); } } |
Explanations:
- The example suggests two ways how to access declared arguments:
- Accessing the argument value: directly returns the argument value for the given argument name.
- Accessing the argument object: offers to use the
getName()
andgetValue()
methods of the argument object.
- Argument names can be specified by strings or by using the
declaredArguments
instance of theJobArgument
class and the argument objects included.
Reading the list of
...
Declared Arguments
Similarly to reading specific Declared Arguments the job has to specify the Declared Arguments by use of the js7.JobArgument
class.
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
class JS7Job extends js7.Job {
processOrder(js7Step) {
// access argument by name
js7Step.getLogger().info('[getJobResourcesArgumentsAsNameDetailValueMap] by name:');
var colorBlue = js7Step.getJobResourcesArgumentsAsNameDetailValueMap()['color_blue'];
js7Step.getLogger().info("argument color_blue=" + colorBlue.getValue());
}
} |
Reading the list of Job Resource Arguments
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
class JS7Job extends js7.Job { processOrder(js7Step) { // accessget argumentlist byof name Job Resource arguments var args = js7Step.getJobResourcesArgumentsAsNameDetailValueMap(); js7Step.getLogger().info('[getJobResourcesArgumentsAsNameDetailValueMap] by name:':'); js7Step.getLogger().info('arguments: ' + args); for (var colorBluearg = js7Step.getJobResourcesArgumentsAsNameDetailValueMap()['color_blue'];in args) { js7Step.getLogger().info('argument color_blue: ' + arg + '=' + colorBlueargs[arg].getValue()); } } } |
Further Resources
...
Overview
Content Tools