JavascriptToBubble - way to bring data back as User instead of text

Hi. Anyone know how to load data in from JavascriptToBubble as Value type = User? I’ve always brought the data back as text

1 Like

Hi,

You have to return a user unique_id, so it will automatically considered it as a user.
It allows you to skip the extra step of doing a search for a user where unique_id = your javascripttobubble’s text

2 Likes

So, ‘{“unique_id”: “bubble user_id”}’?

Do you know if it can include more than just the unique_id?

For example, unique_id and user_first_name and user_last_name?

No, what @mattmazzega is saying is this: Here’s a very simple example. On my page:

When a complex data type is selected as the JS to Bubble’s type, you can feed it a thing by sending it the :unique id of a thing of that type and it will fetch that thing.

So, in this example, when we click the Who Am I? button, we will execute bubble_fn_user and pass it a User’s unique ID as a string. We’ll just use Current User in this example. Here’s the workflow:

^^^ note the quotes - we have to qoute delimit the Bubble part or else we’ll get a syntax error. These can be single or double quotes, depending upon your preference.

In Run mode we see:

image

And when we click the button:

image

The JavaScript to Bubble’s value contains an actual User object and we can access all parameters that are allowed.

BTW, @mattmazzega, I didn’t know about this feature of JS to Bubble!. Thanks for pointing it out! So cool… (So thanks.)

5 Likes

@keith You’re welcome! In fact, I found that quite recently too :slight_smile:

1 Like