Forum Academy Marketplace Showcase Pricing Features

Toolbox plugin - collection of utility elements

Hi @billalbert05,

You’d need to figure out where in the Bubble app to put a breakpoint, and that isn’t something documented by Bubble or easy to find.

If you have complex javascript, I recommend testing on the console first.

I’m glad you find the plugin useful!

1 Like

Ok, glad I wasn’t missing something obvious. I have debugged it in the console to get it to work, but need to step through to see the data being passed etc.

Any guidance would be appreciated.

You might prefer to create a plugin, the plugin editor can set breakpoints.

Oh Ok, will take a look.

hi @mishav,
I am trying to do a simple calculation using server script on api workflow and use that result for the following steps on the same workflow.

what I am doing wrong? Much appreciated!

Hi @d.norkus
There is no document on the server. To return the value, make sure the last line evaluates to the value.

For example:

var x = 100 - Math.abs(100-(100*a/b));
x;

You could leave the last line out, as the variable assignment in this case evaluates to the same thing, but there are cases where that isn’t true, and I prefer to be explicit about what is being returned.

2 Likes

Hi @mishav thanks for the great work! Question, I’m trying to get the acceptLanguage header of the user which seems to be a server-side function, any chance that your plugin could do it?

Thanks!

Hello, I’m trying to start using this plugin, and tried using the action “Run javascript (client side)”, asynchronous box unchecked, with a simple alert(Current user's Name) which is a text field and it returned me a syntax error.

Using alert("some text") works fine.

How can I use, if possible, dynamic expressions?

I looked into the examples but couldn’t make sense of how to proceed in my case.

Have you tried putting quotes around current user’s name?

2 Likes

Oh, great! That did it. Thought Bubble already fed it as a string.
Thank you!

1 Like

Hi @aissa,

Server-side scripts via plugins are run in a sandboxed area, they don’t have access to the part of the app server that handles browser requests.

It is worth reading this section in Bubble’s reference doc: https://bubble.io/reference#ApplicationSettings.language_field

Additionally, on the javascript side you can retrieve the browser’s language via:

navigator.language || navigator.userLanguage

1 Like

Hello, i am using your plugin for running javascript when a button is pressed and the plugin returns a list of numbers through a JavascriptToBubble item, lets say: [1,2,3,4,5]

I have a list of items of a certain data type (POSData) and i need to populate one of the fields for this data type with the results returned. However, i have not been able to do this. I was using a workflow api but because these workflows cannot access elements in the index (JavascriptToBubble item) i cannot retrieve this list and had to use a temporary variable to store this list. However, the temporary variable erases all duplicates which i need.

what can i do to fix this?

Why does running the following code in an expression always throw a toolbox error despite always working in my browser console (I’m just trying to get the index of the selected value in a dropdown)?:

document.getElementById("kitchen_open_time").selectedIndex

Hey @zelus_pudding,

My guess is the element you are referencing is not in the dom when the expression evaluates. Try setting the expression element to not be visible on page load, and then have a workflow event of When page is loaded > show expression.



Looking to accelerate your app development?

Let me turn
:thinking: :tired_face: :confounded:

into
:grinning: :sunglasses: :woman_student:

Development through Coaching at https://uniqueideas.com or schedule a free intro session :gift:

Ken Truesdale
LinkedIn

2 Likes

That seems to have been the case :slight_smile: Thank you! Although, I would’ve thought that this function would re-evaluate every time the dropdown changes values but it doesn’t :confused: Any idea how to get it update with changed values?

I figured it out… without actually referencing the drop down the expression wouldn’t reevaluate every time the dropdown changed. So I made a dummy function that took the dropdown as a dynamic input and then generated the index by direct attribute selection.

function get_index_of_dropdown(dropdown_value) {
    return document.getElementById("kitchen_oioio").selectedIndex;
}

get_index_of_dropdown("Dropdown Test Time 's value");

See:
image

Feelin’ good!

3 Likes

Any constraints in an iframe to use javascript to bubble ?

It works with basic example but when implemented inside a more complex iframe, I got error
bubble_fn_1 is not defined

My goal is to implement VGG annotator, a great tool to annotate images. I customized their code to

  • upload automatically images from a list provided by Bubble ( ok, works)
  • get the result (some text data giving x and y coordinates) into a Bubble’s input : does not work :thinking:

See below :


and
https://bubble.io/page?type=page&name=area&id=annotations&tab=tabs-1

any thoughts ? thanks !

1 Like

Hi @mishav

Is Crypto / AES256 available in toolbox’s server script? Or is this a bubble limitation. I’ve run the following static encryption script, but receiving errors. Just trying to trouble shoot:

@boostsalesgroup Also tried something a similar script with HMAC with require(‘crypto’)

Thank you -

Hey @mishav, et al,

Interesting behavior here, where I set a db value using javascript to bubble element, it fails on the first attempt, and works on all future attempts. I’ve stripped it down to the following basic test:

Gives me:
1rst Click:

2nd Click:

Notice that the amount_number is only showing on the 2nd hit.

If I simply set a value instead of using the javascript to bubble element, it all works fine.

Am I just being a knuckle head and doing something wrong?

Appreciate any help here!

@gilles, I don’t believe you can require NPM modules in Server Script. There’s no bundler/install type feature there. But you can just do this as a server side action plugin.

Setup is roughly the same, but there’s a magic field where you can specify your dependencies.

2 Likes