(This has been asked a year ago, but no answer I can work with, so please forgive me if ask it again.)
I am using several prompts to read some data, then I insert these in a template. All works well.
Now I’d like to read a prompt via JavaScript like so:
// Prompt example
// Using Select
var p = Prompt.create();
p.title = "Select Prompt Example";
p.message = "Demonstrates options for single and multi-option select in prompts.";
var options = ["Mike", "Ugur", "Lilly"];
var selectedOptions = ["Ugur"];
// single selection
p.addSelect("s1", "Select one...", options, selectedOptions, false);
p.addButton("OK");
if (p.show()) {
var s = "Selected: " + p.fieldValues["s1"] + "\n\n";
alert(s);
}
and use the result in my template.
How do I reference the result of the above code in a template?
var person = Prompt.create();
person.title = "Fuer wen ist die Rechung?";
person.message = "Waehle Person aus.";
var options = ["Mike", "Ugur", "Lilly"];
var selectedOptions = ["Ugur"];
// single selection
person.addSelect("s1", "Select one...", options, selectedOptions, false);
person.addButton("OK");
if (person.show()) {
var s = "Selected: " + person.fieldValues["s1"] + "\n\n";
var name = person.fieldValues["s1"];
alert(s);
draft.setTemplateTag("person_name", name);
}
In my template I reference the tag as [[person_name]].
It exists from the point you create it to the end of the action execution run.
I’ve never seen anything to “delete” one, or had a reason to want to explicitly delete one, but you could null it if you needed to - e.g. If you wanted to only populate in certain conditions via a script, but always include it in some final action step template.