Save an expression in a Field (in Data type)

Hi!

How can I save any expression in a Field (in the Bubble’s DB)?

For example: I want to save a text with expression (without value, only a text dynamic expression) for user’s name or other parameters.

P.S. I know about “Copy expression -> Paste expression”, but this very useful option does not fit for my task.

Thank you!

I’m not sure I follow the question to be honest. Can you create a situation in a public app and tell us what you’d like to do in it. In context it’d be easier I think.

You should use a change things action. Have you done the lessons at bubble.is/welcome?

I have done all the lessons.

How I can save this text with expression (from element [Text #1] to field [buffer] in data type [Exp]) and “call out” it from field [buffer] in another Text (in [Text #2]). Then I want see value (text and value of expression) in Preview-mode.

You use an action make change to things in a workflow (like you did in the lesson), and then you access the value of the field using the expression composer

I would recommend doing the lessons again, most users get the most of it after the second time, especially using the hard mode.

I am already using what you have recommended. It’s all right.

My question is straightforward. How do I copy the contents of the text box with the expression and insert it into the database, then to extract in the same form (paste it into another text field).

The Bubble has the opportunity to “Copy expression”, I also need to save this copy in the table and then, when and where I need to insert this expression into another text element (as if I did, “Paste expression”).

Are you asking about editor question or building the app’s functionality?

You say you’re using what I’m recommending, but I see 0 workflow in your app https://bubble.io/page?name=index&id=save-an-expression-in-a-field&tab=tabs-2

I think he’s literally looking to save the string “Name = Current User’s var” as an entry in the database. Is that accurate?

1 Like

YES! :joy:

… and expression should retain its property (dynamic expression)

What’s the use case? What is it you’re trying to accomplish?

I have pieces of text with variables (for: user name, and other parameters).
The variables within the text.

I need to keep these pieces of text (with indicating variables) in the database.
When I need to, I will extract the pieces of text with variable and depending on the context in variables will be substituted in the required values (user name, other more not trivial parametres).

… something similar to a Interactive Fiction

Let me see if I understand.

  • I tell the app my name (name = Andrew)
  • I start an interactive story
  • The interactive story has a line that is supposed to read, “Welcome to the storybook <user’s name goes here>!”
  • You want <user’s name goes here> to be replaced by “Andrew”

Is this what you’re trying to do?

simplistically - yes

If I understand correctly… you want someone to be able to enter …

“Hi there (firstname) from (country) where firstname and country are fields on a bubble table”

… in a text field.

And then for you to be able to display that input and for firstname and country to be displayed in the correct place ?

That is not the problem. How to do I know and doing.

I want store the text with expression-text in the database.

For example abstract “use case”. And don’t need optimization it :wink:

Link to test App
in Redactor-mode (Development):

  • Create Data Type "ExpA" with Field "varA"
    
  • Create Data Type "ExpB1" with Field "varB1"
    
  • Create Input-element "InputX"
    
  • Create Input-element "InputY" (hide for Preview-mode) with initial content: "Text text text ExpA's varA text text!";
    
  • Create Button-element "BtnA" with workflow (when BtnA press): Create Thing [ExpA] -> varA = InputX's value;
    
  • Create Button-element "BtnB1" with workflow (when BtnB1 press): Create Thing [ExpB1] -> varB1 = InputY's value;
    
  • Create Text-element "TextR1" with content (insert dynamic data): Do a searh for... "ExpB1's varB1" (which = "Text text text ExpA's varA text text!").
    


in Preview-mode:

  1. Enter in InputX: “Dragon”
  2. Press BtnA.
  3. Press BtnB1.
  4. and in TextR1 we see: “Text text text Dragon text text!”

It’s work.

How do it if I want create workflow for BtnB2: Create Thing [ExpB2] → varB2 = TextY’s value? When I create thing in list I see only input elements but I want select value by text element.

And most difficult question: how can I import in Bubble’s DB my text with preset variables (dynamic expressions). Which syntax I use for this? … seem on “text text text <expresson>myVariable</expression> text text.”

Sorry for my bad english…

Aha, got it.

You need to use an input instead, and tick “this Input Is Disabled” - that way it will look like a text element.

Thanks, yes I use this variant, but… Text element it is a text element… but current variant (input element in disabled mode) = “solution-crutch” for me.

I understood now, there is no such “function” in Bubble.

What do you think about my last question (import text with preset expressions)?