Plugin not working as expected

Hello,

I have coded a custom plugin for a feature to insert a predefined text at the caret location in a text box.

The feature when implemented on any code sandbox works as expected, however when tested inside the Bubble platform, it doesn’t work the first time it’s executed, only on the second time.

This is where it gets interesting, after the second time the code is ran, it executes the code in multiples.

For example, instead of only placing the predefined text once, it will place it twice, and the next time the function is ran it places the text three times.

Has anyone ever seen this behavior before? Is there a fix action?

Is there a way to accomplish this using basic bubble functions?

This issue is extremely frustrating as I have seen it operational here:

However when I use that exact code, it doesn’t function at all and when I’ve modified it, it will only work as expected in an environment outside of Bubble.

I cannot even seem to get a recording of the issue because it seems to error the entire browser when ran as a bubble plugin.

Here’s a link to the code working in a sandbox:

Depends on how you’re setting up the plugin, can you also share the code in the plugin and where is it setup? For example in the initialize function, in an action you created or other box.

The code in that sandbox is the exact code but I changed the element IDs to import fields.

It’s setup as a client side action only.

Same question as @vini_brito, which Plugin function have you dropped that code into: Initialise, Update or some other function linked to an Action? Maybe you can screenshot your plugin’s backend and share that here?

@edwardbutcher
@vini_brito

I have answered the question, it’s setup as only a client-side ACTION.

I do not have any elements coded. Is that possibly the issue?

Then it’s not the exact code. Also, I suspect that what’s going on here is the “load data” repeat.
Whenever you load data from Bubble the function halts and re-runs with the newly loaded data, so any code before the data being requested must be idempotent.
If this is the case, then take a look into Bubble’s manual about creating plugins, essential reading :smile:

@vini_brito
Thanks for the response, and I can see why you’d think that. I am not actually requesting any data from the database though, its importing the Attribute ID’s from the static text boxes in which the user manually types into the workflow action.

The symptoms do sound a lot like this paragraph though:

Functions that you expect to run once, such as an execution of an action, can actually run multiple times, as we incrementally load the data that the function requests. Similarly, theupdatefunction for an element will be re-run not only when one of the properties for that element changes, but when any data you request finishes loading, or subsequently changes.

@vini_brito,

Thanks for helping. I ended up figuring it out after reading the plugin docs, I guess I should have started there!

1 Like

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