How do I get actual values from List passed to SSA?

I’m building an SSA where a list of texts is passed. I’m then trying to find the index of a particular value in that list. To do that, I have the following code:

image

So ids and answers are the lists, but let’s just focus on ids.

Then I run the following to get the index of a certain id (which I have triple check IS there):
json["Tag"] = ids.indexOf("1631478754886x312173621329264640");

This returns a -1, meaning no matches are found. I discovered this is because indexOf does an exact match search, and the get function that’s available for getting the values from the List object that’s passed through returns an array of objects.

How do I just get a straightforward array of values that I can work with and use functions like indexOf on?

get returns an array of the same type as the bubble list. If you have a list of string you get an array of string, if you have a list of bubble’s things you get a list of objects.

That’s what I thought, but that’s not what’s happening for me. Take a look at this code:

image

I would expect that txt would simply be something like ['value one', 'value two', 'value three']

But it’s not. When I return it and log it directly to the console on the front end, this is what I get:

It’s a bunch of gobbledygook. Oddly, Simply returning ids and answers works fine.

The only thing I can think of is that when var txt is set the ids promise hasn’t resolved yet? Thought I’m not sure why that would be as I’m using await and running inside an async function…

Any ideas?

1 Like

what is the data you pass to the property? can you share a screenshot of the setup on the editor?

Sure, here are the field definitions in the editor:

Here is where I’m passing in the data from the front end:

So I’m passing through a List of unique ids. I am calling this SSA from the front end (not a backend workflow) in case it matters.

If you hover on the last part of the expression what is the type of the end result according to bubble?
for the sake of debugging, have you tried to pass a very simple list of texts for question_ids?
something like arbitrary text 1|2|3 splitby |

I hadn’t, but I just did and that is working. Something about passing unique ids I guess?

As a workaround I might be able to pass the actual list of Questions as Things and get the id from each in the plugin, thought that’s not ideal because I’d have to set up an extra field to select Questions etc, and I’m only using the unique id.

Any other ideas on how to make it work, or why unique ids might be causing issues?

If you hover on the last part of the expression what is the type of the end result according to bubble?

I just tried with a list of unique ids, and I get the same behavior. You can even check with context.isBubbleThing(ids[0]) and you will see that it is indeed a bubble object instead of a string (I tried with a list of users’ ids).
You may have found a bug, or maybe an “expected behavior”

1 Like

Lucky me!

Thanks for your help in troubleshooting, really appreciate it!

1 Like

You could pass the list of things instead of the unique ids and then get the ids with the code.
Something like:

const ids = [];
for await (const thing of properties.yourListOfThings) {
	ids.push(thing.id);
}

The only problem is that according to the docs id should be a method, but in practice it’s a property, and not a function. I wonder if it is “just” a mistake of the docs.