Associating a script expression with a property

Many flow element and connection properties in Switch offer an extra property editor that allows entering a script expression.

String value example

For example, the "Subject" property of the Mail send flow element allows a script expression in addition to a regular explicit value:



Select "Inline value" (the default) to enter an explicit string value in the text field next to the "Subject" label. Select Define Script Expression to enter a script expression in the property editor, which looks as follows:



In this case, when it is evaluated in the context of the job being processed, the script expression should return a string value (or a value that can be meaningfully converted to a string under the JavaScript rules). The resulting value is used as the subject line of the email sent out for the job.

Boolean value example

As a second example, the "Include these jobs" property of a connection leaving a folder allows a script expression in addition to other filter types:



Select Define Script Expression to enter a filter script expression in the property editor, which looks as follows:



In this case, when it is evaluated in the context of the job being considered as a possible match for the filter, the script expression should return a Boolean value, i.e. true or false (or a value that can be meaningfully converted to a Boolean under the JavaScript rules). If the resulting value is true, the job will be considered to match the filter, otherwise it won't.