So I'm trying to make it so that my snippet pulls a patient's name from our electronic medical record but that if the name is not available that the snippet should allow for manual entry of a name (using a formtext). Just curious what {if: } statment I can use so that if the {site: } command errors out that it instead uses a formtext box.
Thanks in advance
Hey @Doc_Krieger,
You could wrap your {site: } command in a catch block and give it some default value if the site command errors out. Then in an {if: } block you could check if the site command has the default value or not. If it has the default value, you can show the formtext otherwise you can show whatever the {site} command outputs.
Sharing an example here:
{currentDate=catch({site: text; page=https://www.timeanddate.com/*; selector=#ij2}, "wrong")}
{if: currentDate="wrong"}{formtext: name=Patient Name}{else}{=currentDate}{endif}
Best
Samay
1 Like
not sure I can use this in this case. Since I'm trying to capture patient names there is no default value I can make it look for.
so think I figured this out actually if anyone is interested. I went through the documentation and saw the catch() function allows textblaze to handle errors and used it to output "not available" when the {site: } command runs into an error. Then I just used simple if statements to make it do what I wanted:
{name= catch({site: text; page=https://.website.com/; selector=.name-wrapper}, "not available")}
{if: name = "not available"}{formtext: name = name_txt}{else}{=name}{endif}
1 Like
@Samay_Jain
oops, sorry, clearly I was a bit sleep deprived and didnt realize that you literally answered the same thing.
Thanks!