How to Reference User Input from a Blueprint Variable
Overviewβ
As part of creating a Blueprint, you'll no doubt have multiple Blueprint 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 Blueprint 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
- Environment Variable
- 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 Vessel.
Now, when the Vessel runs, the reference of ${cool_var_name}
will be replaced by whatever the user enters for that 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 Vessel runs in Platform, your Environment Variable value for cool_var_name
will be replaced by whatever the user enters for that variable.
This way of referencing a Blueprint Variable is less ideal because it will not work the same locally as it does in Platform unless you add the necessary environment variables to your local machine.
You've now successfully referenced user input in your code.