Dynamic text options inside the rich editor

I’m sending an email with a list of stuff. I want to dynamically control the text of each line separately, such as font color. Is that possible inside the rich editor? Even better, I want to show or hide a line of text based on a dynamic condition.

Thanks! :slight_smile:

If you press the button for the rich text editor you should be able to change the colour of the expressions like they are any normal text.
To show/hide text you could have a yes/no condition with the :formatted as text operator and have either the yes or no value as empty, that way nothing is shown.

The text color can be changed in the rich editor, but not a dynamic change, correct?

Can you show me an example of how to use the text operator with the condition? I don’t know how to put that together.

Thanks! :slight_smile:

It seems you are inside a WF action or a plugin. You might not see directly the rich text editor.

In order to see it, you may need to pass through the “Arbitrary text” datasource, see image below

Then you use BBCode to format your text as you wish.

Example

PS: You don’t actually need the Rich text editor for the BBCode to be evaluated inside Bubble. But make sure the mail provider that will get your call, supports BBCode.

Just to add to what @stephane_hildbrand said… there is a plugin that converts BBCode to HTML. I use it for exactly that purpose.

Thanks Stephane, I don’t think you understand what I’m asking.

Correct, this is in a WF action, and I can enter the rich editor.

What I want to do is dynamically condition the text, e.g. When Input X = Input Y then font is [new color], or [make invisible], just as you can in a text on a page.

:slight_smile:

In my very last screenshot, you can see a dynamic text being placed inside the BBCode. This is because you talked about customizing the color, and formatting of a text.

With a dynamic expression you can have an expression that outputs the color you want, or the formatting you need.

If you need more than just a few colors and formatting, I would suggest other techniques. Because dealing with that with only dynamic expression can be heavy.

I once made a loop of backend API workflow that construct a whole text by adding or not fractions of texts.

Loop A will or will not add text-1 to the output, then pass the result to loop B, that will or will not add text-2 to the output, then pass the result to loop C etc…

Depending on your need, that might work as well.

In your rich text editor value, simply create a placeholder value like {{color_1}} and then when you want to use any color you choose for the color just do a find and replace expression where you find {{color_1}} and replace with whatever color you want to use hex value, and the replace with value can be a dynamic expression itself and therefore conditionally set.

in terms of show or hide a line of text, if there is some determined value it begins and ends with you can extract with regex to remove it…

What exactly are you trying to hide/show in terms of lines of text and what is conditional determining factor of hiding or showing the lines?

Boston, I want to compare the user’s answers to 24 multiple choice questions with the correct answers. In the email I want to report only the wrong answers. So I was trying to condition each line with: [user answer] is not {correct answer] and somehow highlight the answers that were wrong.

Stephane, you did it, you gave the idea to build a text field in pieces! I don’t need a backend WF, I can add or not add a text string to a field using the Only when condition for each answer. That seems to be the simplest solution.

Thanks everyone for being on the team! You’re all great as always! :slight_smile:

You don’t need to make changes To current user for this. You are just wasting workload units doing so.

For you use case, in the email body just put the conditional expressions as pieces, or setup a series of custom backend workflows with return data to build the email.

Making changes to the current user as your screen shot shows costs 1.12 WU each time, but expression directly in email or custom backend workflows are free.

Boston, good points, thanks!

That’s interesting that expressions in email do not cost WU. Unfortunately I still have not learned how to put the condition expression in the email at my level of programming (i.e. no code).

I believe I cannot use a backend workflow as all my correct answers are saved as custom states on the page, then I would have to transfer 24 states to the backend.

What if instead of saving the text in a user field, I could use another custom state. That would work for me as well since it’s only a 1-time use. Does that help increase speed and reduce WU?

:slight_smile:

It’s not clear to me what that text value you are saving to current user is, my assumption was it’s a single line out of many and you were going to save each line individually. If you are taking 24 custom state values and sending in email, just send the email in workflow on page. Expressions in workflow for email body are same as expressions when saving data to database.

In the body of a Send email action, the dynamic editor allows me to select from various data sources but I don’t see how it will allow a condition on an individual line of text, as in, “Only when input x = input y then make text visible.”

So the only way I see how to do it is use an action that has the ability to Only when. Then it will save only the texts I want in Text 1. Correct?

You make that condition and add the formatted as text operator…it’s an inline conditional basically. The formatted as text evaluates as all conditions to, either yes or no, and you can put different values into the yes and no field. Play with formatted as text operator to get an idea of how it works.

Hi again Boston.

I ran into an unusual bug as I was working on this. When using the Dynamic editor inside the Send Email workflow, certain options I needed were not available in the dropdown, such as custom state and a page element. Wait a minute–that’s puzzling because both of these I had previously used. It wasn’t until a few days later that I rebooted my computer and magically, the options I needed reappeared. That’s some bug! :thinking: Have you run into that before?

I have it working as I want, by saving the text string into a custom state, so I’m done working on it.

Thanks to both you and Stephane for your tips, exactly what I needed.

:slight_smile:

Yes, for some reason we are nearly 18 months after reporting the bug that sometimes when adding/changing some data sources of an element that is not reflected so dynamic expressions do not pick it up. It’s inconsistent but I saw it again yesterday and needed to refresh my browser to get the data recognized.

Well that does it for me with Chrome. I get increasing browser errors fairly regularly now with Chrome but not Edge. Also have a long-term bug that I submitted to tech support in June that they haven’t concluded, another error that does not appear in Edge.

With Edge:

With Chrome:

Freaking ridiculous, because I don’t have enough trouble on my own without a browser fail. Use Edge, not that other one!

:slight_smile: