Forum Academy Marketplace Showcase Pricing Features

Toolbox plugin help - server script

Hi all,
I’ve done a bunch of googling but can’t find anything that talks about how to use the server script action:

I have a feeling this action does what I want it to do as it allows you to return any datatype you want but I need some direction on how to use it.

There are plenty of videos on how to use the “run javascript” action but not the “server script”.

Anyone have any useful links?
Thanks
Paul

Hi @paul29

Put on the last line the result.
Here is an example of a simple list:

const List = [];  // comment : initialize the List.

if     (data == "Hi") {
    List[0] = "firstname", List[1] = "english", List[2] = "hi_firstname" }
else if (data == "Hello") {
    List[0] = "lastname", List[1] = "english", List[2] = "hello_lastname" }

else { List[0] = "firstname", List[1] = "english", List[2] = "hi_firstname" };

List;  // last line if you want some result, in this case Result List.

___ AND

image


FYI
In Javascript list started with 0,1,2 …
In Bubble list started with 1,2,3

Thanks for this. Do you have any insight as to how to get this to work when the return type is an actual data type? I am trying to run some code that returns the data type in the proper format so that bubble can properly understand it as if it were a normal thing.

If that’s a little confusing, let me know and i’ll explain what I mean in more depth
Thanks again.

Hi @JohnMark sorry to bug you but I just wanted to follow up and see if you had any insight into my follow up question. Thanks

1 Like

@paul29 :raised_hand:
Here is the working example of server script which generates JSON…

Here is the link of the editor which covers all the toolbox plugins functions

4 Likes

Hi @viquarahmed07
Thanks for your reply. Apologies, maybe I needed to explain a little more. I am setting up algolia as an autocomplete feature. I’d like to make the api call in javascript and return it as a datatype so that I can manipulate it in normal bubble fashion (i.e. 's name, 's id, etc).

The reason I’m not calling algolia as per the normal api connection is because there is a slight delay making the UX no good as autocompletes need to be super fast.