Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

ConstructorArgumentExplanation
js7.JobArgument()

[string] argumentName

Specifies the name of the argument from a string. Argument names are case-sensitive

[bool] isRequiredOptionally specifies if the argument is required. If required and the argument is not declared with the workflow and if no default value is provided then an error will be raised.

[string|int|bool] defaultValueOptionally specifies a default value in using one of the indicated data types.

[enum] displayModeOptionally specifies the js7.DisplayMode.MASKED enumeration value that prevents argument values from being logged.

...

Code Block
languagejs
titleExample for implementation of js7JobArgument with JavaScript
linenumberstrue
class JobArguments {
	workflowPath = new js7.JobArgument('js7Workflow.path', 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.path');
		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.workflowPath.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.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));
     }
}

Explanations:

  • The example suggests two ways how to access declared arguments:
    • Accessing the argument object: offers to use the getName() and getValue() methods of the argument object.
    • Accessing the argument value:

...

    • directly returns the argument value.
  • Argument names can be specified by strings or by using the declaredArguments instance of the JobArgument class and the argument objects included.x

Example: List Declared Arguments

Code Block
languagejs
titleExample for implementation of js7JobArgument with JavaScript
linenumberstrue
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 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 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]);
		}
     }
}

Explanations:

  • 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.x

Methods for Arguments


Methods for Return Values

...