How-To: Reference User Input from a Template Variable
Overview
As part of creating a Template, you'll no doubt have multiple Template Variables that users can fill out. To access the user input, you'll want to use the Variable's Reference Name. This how to guide will walk you through the steps to reference those Template Variables in your code.
Steps
For the examples below, say we have an example where the Variable's Reference Name is cool_var_name
.
Your Reference Name is case sensitive. Make sure you type it exactly the same.
Platform UI
Locate the field where you want user data to flow into. Common locations are in the Argument Value or the Environment Variable Value field.
Use the format of
${VAR_NAME}
, replacingVAR_NAME
with your Reference Name. For our example, this would be${cool_var_name}
Save the Task.
Environment Variable
In your code, set a variable to access data from an Environment Variable whose name matches the Reference Name.
Save and/or re-upload your code depending on your setup.
Now, when the Task runs, the reference of ${cool_var_name}
will be replaced by whatever the user enters for that variable.
You've now successfully referenced user input in your code.