I want to create a snippet that leverages PopUps to let me choose between “Stacy will be providing tech support…”, “I will be providing tech support…”, and “Stacy and I will be providing tech support.”
I know how to do this. However, later in the snippet text, I say, “…so please send us materials…” and I’d like that to say “please send her” or “please send me” depending on which option I chose in the popup.
Is this kind of conditional possible?
1 Like
Hi Seth, thanks for your patience. TextExpander doesn’t support conditionals. I think your most efficient solution would be to have three optional sections, each with the complete phrase. Would that work for your case?
@SethDimbert Yes — what you’re asking for is totally possible with some JavaScript in your TextExpander snippet!
Here’s an example that lets you choose between different tech support statements, and then dynamically adjusts the pronoun in a follow-up sentence:
//%filltop%
var supportChoice = "%fillpopup:name=Support Choice:default=Stacy will be providing tech support:I will be providing tech support:Stacy and I will be providing tech support%";
var pronoun = "her";
if (supportChoice.startsWith("I")) {
pronoun = "me";
} else if (supportChoice.startsWith("Stacy and I")) {
pronoun = "us";
}
var output = `${supportChoice}, so please send ${pronoun} the materials in advance.`;
output;
What this does:
- You select one of three subject lines from the popup.
- The script sets the correct object pronoun based on your choice:
- “her” if only Stacy is providing support
- “me” if it’s just you
- “us” if it’s you and Stacy together
- The final output ties it all together in a grammatically correct sentence.
Let me know if you want to build this out further with other variables like verb conjugations or possessive pronouns. Happy to help!
1 Like
That worked! It took me a minute to figure out how to create a Javascript snippet and embed that inside another snippet, but it works like a charm. Thank you so much.
1 Like