[Plugins for Beginners]: Accessing Input and Output Fields in Plugin Action Javascript Code

WHY IS THIS NOT PART OF THE OFFICIAL DOCUMENTATION?

I SPENT HOURS UNTIL I FOUND OUT ABOUT USING .get

1 Like

I have created a plugin but I am getting a weird behavioural response.

I am able to get the JS to update the variable. Great.

On a workflow in Bubble, I run the plugin action with success (this updates the variable and returns it). For the second step of my workflow, im simply trying to save that data into a thing.

The workflow is initiated by a button click. This does not work on the first click. It only works on the second click.

To check I am not going mad, I placed a text element to display the data e.g “Plugin’s A Data”. On the first click, this updates correctly but my thing is still empty. Hmmmm. Then I click it again and success! It saves the data to the thing.

My only guess is that because the saving aspect is another step, it’s causing a weird Bubble bug.

As Bubble won’t play ball, is there an alternate way such as getting the plugin to update my Thing if I pass it to it? This way it would happen in the same workflow action. It would HAVE to work then surely.

The Plugin action is client side and currently I save the data into an exposed state.

Have you Tried adding a pause. Could It could be trying to save before the state has been updated?

@jared.gibb Yes, I tried that. I did a 5,10 and 20 sec pause. Then I clicked the button twice in quick succession and it saved. I have emailed Bubble with a video. Its very strange because the data is there on first click as shown by the text element but for saving to a thing, it seems to require 2 clicks.

Still waiting! I’d love to see this be easier.

Like I should be able to cal out to Firebase, return an array of objects, and then use that without using the server side action (which does accomplish this). Right now, I call out to Firebase using a client side action and return several lists. 1 for each property in the object is rather return. It’s a workaround but using the response as an array of objects instead of several lists would be ideal. And to do it as a client side action!

@antony This read is so helpful, thank you so much for compiling.

I am following the steps to import a bubble “thing” for a client side action . The “Thing” is a “List of Assets” which is basically a custom data type with a bunch of fields (Asset Name, Asset Type etc…).

I am trying to get the field value names using the .listProperties() function

But for some reason I am getting an error saying that the listProperties function does not exist.

Would anyone be able to help as to why I am getting this error?

Thanks so much again,
Adam

Hey @jared.gibb , I think I am having a similar issue, I am getting the same result. I think it may be to with the data type being undefined. I am trying to get the listProperties() function to work to make I am receiving the correct data through the plugin.

Do you know remember how you solved this problem?

Thanks

Hi, This post was so useful I feel compelled to provide an update since bubble changed how Server-Side plugins work this year. Specifically, I am referring to how Server-Side Actions were changed to “Async” functions.

The change to asynchronous processing causes “property” get() functions to NOT work for properties of type “Any Thing” that are lists,

Single gets still work without the Await eg:
var anything = properties.anything;

BUT getting the length of a list requires the Await eg:

var length = await properties.anythinglist.length());

AND

getting data requires (2) awaits as this no longer works:
var anythinglist = properties.anythinglist.get(0, properties.anythinglist.length());

Now you need to split the line into (2) lines so each may have an Await:

var dataLength = await properties.anythinglist.length());

var data = await properties.anythinglist.get(0, dataLength);

and for referernce: Updating to Plugin API v4 | Bubble Docs