Page History
...
JS7 offers an API for JVM jobs are executed in the Agent's Java Virtual Machine.
- Java Jobs
- JavaScript Jobs
...
Argument Sources
Arguments to jobs originate from a number of sources:
...
The js7.Job
class is an abstract class that has to be is implemented by a JS7Job
class in the job:
...
Method | Argument | Return Value |
---|---|---|
processOrder() | [object] js7Step | n/a |
Objects
Object | Purpose | |
---|---|---|
js7Step | The build-in object js7Step provides a number of methods | |
Method | Argument | Return Value |
getLogger() | [string] message | n/a |
getDeclaredArgument() | [string] argumentName | [object] argumentObject |
getDeclaredArgumentValue() | [string] argumentName |
|
getAllDeclaredArguments() | n/a | [object[]] argumentList |
Example
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
class JS7Job extends js7.Job { processOrder(js7Step) { js7Step.getLogger().info("Hello World"); } } |
...
- Users implement a class for arguments with an arbitrary name that creates objects for declared arguments
- Users instantiate the class for arguments in their
JS7Job
class implementation.
Constructor
Constructor | Argument |
---|
Explanation | |
---|---|
js7.JobArgument() |
|
Specifies the name of the argument from a string. Argument names are case-sensitive | |
[bool] isRequired |
Optionally specifies if the argument is required. If the argument is not declared with the workflow and if no default value is provided then an error will be raised. | |
[string|int|bool] defaultValue |
Optionally specifies a default value in one of the indicated data types. | |
[enum] displayMode |
[object] argumentObject
Optionally specifies the js7.DisplayMode.MASKED enumeration value that prevents argument values from being logged. |
Example: Access Declared Arguments
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
class JobArguments { workflowPath = new js7.JobArgument("'js7Workflow.path"', falsetrue); } class JS7Job extends js7.Job { declaredArguments = new JobArguments(); processOrder(js7Step) { // option 1: access declared argument object // option 1.a: access declared argument object by name js7Step.getLogger().info("'[GetDeclaredArgument] by name:"'); var da1declaredArg1a = js7Step.getDeclaredArgument('js7Workflow.path'); js7Step.getLogger().info("'declaredArgument: "' + da1declaredArg1a.getName() + "'="' + da1declaredArg1a.getValue()); // option 1.b: access declared argument by object name js7Step.getLogger().info("'[GetDeclaredArgument] by object name:"'); var da2declaredArg1b = js7Step.getDeclaredArgument(this.declaredArguments.workflowPath.name); js7Step.getLogger().info("'declaredArgument: "' + da2declaredArg1b.getName() + "'="' + da2declaredArg1b.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.path')); // option 2.b: access declared argument value by object name js7Step.getLogger().info("'[GetDeclaredArgumentValue] by object name:"'); js7Step.getLogger().info(js7Step.getDeclaredArgumentValue(this.declaredArguments.workflowPath.name)); } } |
...
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 value from loggingbeing valueslogged 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 allArgs = js7Step.getAllDeclaredArguments(); js7Step.getLogger().info('[getAllDeclaredArguments]:'); js7Step.getLogger().info('all declared arguments: ' + allArgs); for (var arg in allArgs) { js7Step.getLogger().info(' ' + arg + '=' + allArgs[arg]); } } } |
...
Overview
Content Tools