Using a list of text in a visual element

Hi, trying to use a list of text (JSON blobs) that come from items in bubble.
I have the code working with a single item (eg. Current cell's Thing's jsonStr) - I just receive the string, and then in the plugin code I use JSON.parse(jsonStr);. Easy peasy.

However, when I send a list instead (eg. Search for Things: each item's jsonStr) and tell the plugin that I’m receiving a list, the JavaScript object that I get is pretty cryptic (in this case the property is called geojsons):
Screenshot 2024-02-02 at 11.27.55 AM . Any tips on how to get the text items out of this object?

This drove me mad forever when working on server side action, the array of texts is properties.geojsons._pointer

Just noticed you said plugin element though, not sure if it is handled differently :flushed:

1 Like

What I believe is that you get a list of text, but not a list of object. It’s hard to know exactly because we don’t see what is in the field of jsonStr, but what I think is that you get something like
Json parse will give a valid json for one item
Not you are getting a list of test like:
But this cannot be parsed a JSON, because it’s not a json array. You need to convert this to a valid JSON array (‘[{“from”:“datafrom”,“to”:“datato”},{“from”:“datafrom”,“to”:“datato”}]’) if you want to use it with json.parse


Thanks for the pointer! Great that that works on the backend.

Unfortunately properties.geojsons._pointer is not accessible on the frontend:
Screenshot 2024-02-02 at 1.18.56 PM

I guess I have to assume that this is just an unfinished feature at this point, and the only thing to do is mash them together into an array by prepending “[”, joining on “,” and appending “]”. Obviously this is far from ideal since it (aside from being ugly and hard to understand) has to be done by the plugin user in the app editor, rather than in the plugin.

Not you are getting a list of test like: ‘{“from”:“datafrom”,“to”:“datato”}’,‘{“from”:“datafrom”,“to”:“datato”}’

I don’t seem to be getting any kind of list or even a string. I’m just getting this weird object with get() and length() functions :person_shrugging: . See the screenshot above which is from console.log()ing the object that I get. If I try to cast it to a string I just get everyone’s favorite [object Object].

You need to convert this to a valid JSON array

Where would I do this if I don’t have access to the data in the plugin at all? I have a workaround to do it in the app editor (see above) but it’s kind of a mess.

Yes, I forget that, to get the items list, you need to follow the correct function. You need to get list based on length following this example:
properties.customfieldlist.get(0, properties.customfieldlist.length())

This is all explained (but without example) in the show documentation of update action (and this is available in update… don’t try to use this in initialize, where only context and instance are available)


That sounds very promising, but when I actually call the length() function I get an error: run.js:201 Uncaught TypeError: _thing.length is not a function:

Screenshot 2024-02-02 at 2.00.20 PM

Where do you call it? Can you share plugin editor screenshot?

The plot thickens: if I set a breakpoint on run.js:201:2463 in Chrome, I can inspect _thing. The value is, similar to what you suggested earlier, a concatenated version of all the strings, in the formtext1, text2, text3.

Then the problem remains how do I access that value! And why is it not an array as Bubble’s frontend code seems to expect?

Ahhh, I think I figured it out. The issue seems to be that I had been toggling the “is a list” setting on the Field (inside my plugin element) and then altering my existing usages in the app. It seems something was broken about how that works. When I deleted the custom elements within the app and then recreated and reconfigured them, I was finally able to use the .length() and .get() functions.

Thank you @Jici !

1 Like