Using Toolbox plugin & Javascript to trigger a workflow when event = "success"

Hi All,

I don’t know javascript, but I’m trying to learn it to solve this problem. I wondered if anyone may be able to point me in the right direction with this question? I’ve been struggling with it for days!!

I’m trying to use the Toolbox plugin to trigger a Bubble workflow when the result of the event is a “success”. How would I approach that with the following code?

https://jsfiddle.net/rg01vh3z/

I think this part is pertinent but I don’t know to incorpate something like “bubble_fn_success(“success”);” into the code in order to trigger the workflow.

if (result.event === "success")

Any suggestions? Thanks.

1 Like

Hey Alex,

Not at my PC right now, but from memory:

  1. Put the JavaScript to Bubble element on your page and follow the documentation to set it up. Give it a suffix of “close” for example.

  2. Enable the “trigger event” checkbox.

  3. In the workflows tab add a workflow “when a JavaScript to Bubble event is triggered” → do whatever actions you need like closing a popup etc.

  4. Back in your script try:
    if(result.event===“success”){bubble_fn_close()};

Then elsewhere in that script define the function:
function bubble_fn_close(){return}

I think that should work - the function gets called and doesn’t do anything however the plugin should register the event and trigger the workflow at point 3 above.

Hope that helps!

Rob.

2 Likes

I just looked at it, where is your js script?

I added it to an HTML element and it seems to be working (apart from of course what I’m trying to achieve in this thread :slight_smile:

I made the changes

bubble_fn_close(true)
1 Like

I just saw the jsFiddle, let me make the changes
if (result.event === "success") { myUploadWidget.close(); }

This is where you want your bubble_fn_close(true) correct?

I believe so. Honestly, I’m just delving into all of this and I have very little knowledge of javascript. I just had to use it in this instance.

I really appreciate both of your help! It works!

You can test it out now, should work as expected.

1 Like

Thank you VERY much.

Related question:

This page serves as a way for users to be able to upload video. After that’s successful, they’ll be taken to another page, which is why I was trying to get this working to trigger that event.

However, because users upload the file directly through the browser and it’s uploaded to Cloudinary for storage (as opposed to into Bubble database/AWS and then to Cloudinary) I’m running into this problem where I’m trying to figure out how to store some kind of unique identifier for the file and create a database entry for that user so that when the file is uploaded, I know which file to retrieve from Cloudinary on the next page (or in the future). Otherwise the upload modal disappears and I have no idea what the video file is!

Any thoughts on how to approach that? Does that makes sense? Either way, I appreciate your help from before.

Like I said, I’m not a developer, so I’m trying to figure this all out of the fly. I think it may be the public_id, but I don’t exactly know how to go about this in Bubble + with javascript: Upload API Reference | Cloudinary

That depends if Cloudinary returns anything after the image has been uploaded. Let me check it out.

So it returns all of this:

You can return any of these values to Bubble using the same JStoBubble element you have. You just have to change the “yes/no” to “text”

OK awesome, I didn’t know you could see that in the console. But how do I specifically structure that in the script to focus on say the “public_id” parameter?

Sorry to have to ask so many questions.

Can you jump on a call right now? faster to explain over the call

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