Versions Compared

Key

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

...

  • 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

...

Code Block
languagejs
titleExample for implementation of JS7Job with JavaScript
linenumberstrue
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() and getValue() methods of the argument object.
  • Argument names can be specified by strings or by using the declaredArguments instance of the JobArgument class and the argument objects included.

...