JS2Bubble List Parameter

Hi all! I am using the Javascript 2 Bubble from the Toolbox plugin. I use this a lot and have no problem sending one or more parameters to the event and using it in Bubble.

But today I’m having a problem when trying to send a parameter that is a list. This is the first time I’ve needed to send a list this way. I cannot figure out what is wrong here. I appreciate any help you can provide.

The objective is to trigger an event from inside a reusable element that will use a list value from the reusable to populate a state on the main page (I can’t do that directly because of scope — I can’t see the page from the reusable element).

Here is my setup:

The element on my page. I am sending a list of type Context:

This is the Action inside of my reusable element. The multidropdown is of type Context:

This is what I get after running the script. Notice that outputlist1 is empty instead of containing the list (which did have values).
Screenshot 2024-05-11 at 9.17.02 PM

And this is the Action that fails because the value is empty instead of containing the list (I don’t know if you really need to see this, but I’m including it for completeness):
Screenshot 2024-05-11 at 9.15.08 PM

Thank you!

Can’t help but notice that you’re using the outputlist1 but haven’t checked the Multiple Outputs checkbox.

When working with JS2Bubble if you’re not going to use the multiple outputs: just select value is a list and pass the list directly into the bubble_fn_suffix([list]) function. If want to keep using Multiple Outputs(output1…4, outputlist1…4) just check the checkbox.

Thanks for your reply. You’re right that I missed the Multiple Outputs checkbox. But actually it was checked at first, but ended up unchecked as I was troubleshooting. The result was the same. That list parameter is still empty.

In fact, I’ve been using the multiple output for all of my parameters (for single values, not lists) mostly because I cannot figure out how to use the passed value. If you have an example of this it will be appreciated.

It might also be something in my Javascript, because I often (but not always) get an error. This is the error with the above configuration:

So, I don’t know if there’s something missing on your part but I will leave an example on how I use the lists on JStoBubble, both ways, using Multiple Outputs and as a single List.

The elements:

The run js assigning the values:

Display:

If you want to debug your specific problem, remember you can use console.log to check what is coming as your “properties.paramlist1” value.

Thank you for the examples. I was using the paramlist1 box to enter my values but I tried it your way as well. I got the same result. That at least tells me that maybe I am not necessarily getting it wrong.

I think the key is the error that often appears (posted above) which states “Trying to send an invalid array to Bubble”

Is there something about using a custom data type that’s a problem? I’m trying to send the value of a multidropdown which contains 0 or more of this custom data type. When I tried using your method and in the JS I added

let contexts = This Multidropdown's value

it was red to indicate an error. It wasn’t until I added :each item's uniqueID it would accept it. But this still did not solve the problem.

So is there something about the custom data type, or maybe the value of a Multidropdown that is a problem?

Thanks.

When using a custom data type, you have to specify that on the JS2Bubble element, also, check what is the content of the “This Multidropdown’s value”. I don’t really know in your specific case but remember that when using Bubble Data Types you should know how to use them:
https://toolboxdocs.netlify.app/run-js#bubble-type-param

Using bubble datatype instead of list of text:



Sure, I’ve specified type Context which you can see in a screenshot in the original post. Also, I’ve verified that my Multidropdown’s value evaluates to a list of Contexts, so I cannot figure out what is happening. I can’t say for sure, but it feels like a bug in the plugin to me. Of course, I’m open to trying anything to make it work.

Thanks again for your help.

Check the code I used to load the list from a bubble data type(RUN JS):
image
You’re using properties.paramlist1 as is. If that don’t work, feel free to setup a similar example on a new bubble page and invite me to collaborate, I’ll check it out when I’m free.

I did follow that code and instead of the properties.paramlist1 method, I cleared that and used dynamic input in my JS code to include my Multidropdown’s value where you have the variable assignment. This is what I was trying to describe where it was red (error) until I added :each item's uniqueID at which time it turned blue. It’s as if it did not accept the data type.

Of course this script is not in the same place where the data type is defined in the JS2Bubble element, so I don’t know what the issue is.

I’m on a Personal account and cannot invite users, but I’ll set up a new free example with the same steps and open the access. Thank you for offering to look at it.

This topic was automatically closed after 70 days. New replies are no longer allowed.