Work with variables, scripts, and expressions
26R1 reference · Documentation-based tutorial draft · Not executed in IFS
Treat variables as an interface
Section titled “Treat variables as an interface”Document each variable’s source, type, scope, writer, consumer, and missing-value behavior. A matching name does not prove that two operations supply the same type.
| Variable | Type | Written by | Read by |
|---|---|---|---|
ExternalReference |
Text or missing | Trigger mapping | Validation script |
referenceMissing |
Boolean | Script Task | Gateway |
relatedRows |
Collection | API Read Collection | Sequential subprocess |
deliveryReceipt |
Text | REST output mapping | Outcome check |
Avoid the reserved ifsBpa prefix for your own variables. Internal variables are populated at particular stages; do not assume they exist at the start of every trigger type.
JavaScript task versus expression
Section titled “JavaScript task versus expression”A Script Task executes statements. An expression evaluates a value for a mapping or condition. Use the syntax belonging to the field you are editing.
Original script example:
var value = execution.getVariable('ExternalReference');var cleanedReference = value == null ? '' : String(value).trim();execution.setVariable('cleanedReference', cleanedReference);execution.setVariable('hasReference', cleanedReference.length > 0);Gateway expression:
${hasReference == true}These are teaching fragments, not an assurance that every modern JavaScript feature is supported in the target engine. Prefer simple syntax and validate against the installed scripting runtime.
Inspect types as well as values
Section titled “Inspect types as well as values”In Inspect, unquoted true is interpreted differently from the string "true"; True can be treated as text. Quoted numbers also differ from numeric inputs.
An internal enum such as ifsBpaProjectionOperation can be an enum in normal execution and a string in Troubleshoot. The documented comparison for that case uses value comparison:
execution.getVariable('ifsBpaProjectionOperation') == 'UPDATE'This is a specific compatibility case, not a reason to remove type checks from every script. Test both inspection and the originating operation.
Mapping and scope checks
Section titled “Mapping and scope checks”Task input/output mappings can introduce local values or overwrite existing values. Use different names for unrelated responses and ETags. User form IDs become variable keys, so reusing an ID can overwrite a value.
Capture a small execution and inspect the variable immediately before and after the task that is supposed to produce it. A variable existing at the end does not establish that it was available when a gateway evaluated it.
Failure cases to test
Section titled “Failure cases to test”Test missing, null, blank, whitespace, normal, maximum-length, and unexpected-type inputs. For collections, test zero, one, and multiple items. For dates and timestamps, follow the time-zone guide rather than relying on a browser’s local parsing rules.
The first-validation template contains a pure decision script that can be checked locally. Local JavaScript tests verify its logic only; they do not reproduce IFS serialization, variable scope, grants, or transaction behavior.