Back to All

$self is not defined?


Please explain the use of $self in the Value field of a job input spec. I don't know when and how I can use it. For example, say the ID of my input parameter is called 'quality'. In the JavaScript expression I want to enter in the Value field, it seems I must refer to the parameter as $job.inputs.quality, but I thought I could also do $self.quality. In the documentation at, it says:

In the command line bindings for the tool inputs, $self is set to the value of the input. In other words, in this context $self is just $job.inputs.<input_id>.

According to that documentation, I should be able to use an expression such as "$self || 5" to create a default value of 5. But when doing so, I get this error when trying to run my tool:

This task ran into a problem during execution and did not finish.
Failed to start trimgalore. Failed to build command line. Failed to build command line. Failed evaluating expression $self || 20. org.mozilla.javascript.EcmaError: ReferenceError: "$self" is not defined. (script#1).

So why does it say that $self is not defined?