Passing Lists to Server Side Action acting funky

I had a plugin action working perfectly client side, then I realized I need a npm module so I switched to an SSA and the way the values show up don’t seem to match documentation.

The documentation references in the fields is:

Because console.log is also not working server side, I’m passing values back to client side to log them in the browser:

Here’s the relevant SSA plugin code:

Based on the documentation I would think that the ids would give me a the list of strings and the raw would give me an object, and length would return a number, but that’s not what I get.

When running, here’s the output:

The raw input contains the full list, and length is blank.

Any idea where I’m going wrong here, or is this a bug?

I assume that you are working with the new v4 for ssa.
get and length methods of a list are async functions. Your ids is a Promise which stringified is "{}" and of course is not a number.

1 Like

Not sure, v4 of what, and how would see what version I’m on? The documentation doesn’t say anything about them being async functions.

Side note - why would these simple functions be asynch? That would seem to complicate things unnecessarily. Is it because they are operating on potentially very large lists? Also, is this different for client side actions? This was all working for me when it was in a client side action.

the docs are short. It’s always a good idea to read them, you can find code examples as well.
Plugin version is in the “shared” tab. Make sure to use v4 because v3 is not going to work anymore in january.
Unfortunately only ssa got updated to the async api, so yes there is a difference.

1 Like

Thanks, I wasn’t aware of those docs, I was just referencing the documentation that’s available on the plugin action page, which frustratingly doesn’t say anything about them being async functions. Could have saved me a lot of headache!

I’ll update it and see how it goes.

1 Like

Follow up here - I changed to async but I’m strangely getting the correct output for one of the lengths, and while that seems to be working, I’m now encountering an issue where the lists are of objects, rather than strings, which is what I was expecting by making the field a string.

Specifically, I’m trying to do this operation:
but it’s returning -1 because indexOf uses a strict comparison. How can I convert ids to strings instead of objects?

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