Toggle field and decision statement combination

Toggle field and decision statement combination
Why does the third line default to on(yes) while the second line defaults to no?

{chart="Diabetes"}
{=testregex(chart, "Hypertension")}
{formtoggle: name=HTN; default={=testregex(chart, "Hypertension")}}{endformtoggle}

Hi @N_Saito ,
Sorry for the delayed response.

Form defaults cannot rely on a variable.

If you change it to {formtoggle: name=HTN; default={=testregex("Diabetes", "Hypertension")}}{endformtoggle} you would see the behavior you need.

1 Like

Hey @N_Saito

If you can use code blocks in your snippet, then the following would work for you:

{run: chart="Diabetes"
HTN = testregex(chart, "Hypertension")}
{formtoggle: name=HTN}{endformtoggle}

Note that {run} block runs only once. If you want to run more than once, consider using a {button}. More info here Text Blaze | Code Blocks Reference

1 Like

@Gaurang_Tandon

Using the “run” command certainly does what I want. Thank you.
If I could make one point, it would be that the “run” command is printed out. Of course, this doesn't affect the inserted text, so there's no major problem with normal usage. I'd be happy if you could improve it.

Thanks for pointing that out. You can enclose the {run} command inside a {note} command with preview set to no to hide it from the print output.

{note: preview=no}{run: x=1}{endnote}{=x}

Let me know if it works for you.

1 Like

@Gaurang_Tandon
It works, Thank you.It is a great idea to be able to use the preview command to set whether or not to print a range of NOTE settings.