Forum Academy Marketplace Showcase Pricing Features

Update database record from backend API Workflow

I have a database type with 3 fields: TaskID, Input, and Rephrase.

The TaskID and Input are added to the database record at one time, and then after a delay (a custom API processing), the Rephrase is returned through a backend API post request. If I add the API response to the database as a new record, it works fine, and I can see the Rephrase in my database. However, I want to update the existing record that contains the TaskID and Input. Attached is my configuration, what am I doing wrong? The current configuration does nothing.

What is the name of the data-type which you say has three fields? Is that “Rephrase”?

What are the parameters to the API workflow receive-response?

Hi Ivan.

It looks like you’re passing task_id to the API call and then searching for the Task based on that. As a first step to improve this, I’d suggest passing the new Task itself to the API, then you don’t have to search for it in your “Make changes…” step.

Presumably on your page you’ve got something like:

Step 1 - Create a new Task
Step 2 - Schedule API call

The API call should pass the parameter Task = results of Step 1.

Doing it this way is good practice anyway as it ensures your API call doesn’t run before the task exists (which could potentially be the problem you’re describing).


Hi James,

Take a look at the screenshot.

The bottom record exists in the database prior to the backend workflow firing/the API response returning to bubble. What I would like to happen, is that when the API response is returned, it searches the database for the matching taskID (which is included in the API response), and if it finds a match, updates that record to fill in the Response field (also included in the API response.

You’ll see in the top record in the screenshot, that when I try to “Create a new thing” instead of “Make changes to a thing” it correctly adds the API response to the database. This tells me the API response is working correctly, but for whatever reason, bubble isn’t able to update the preexisting record based on the taskID. My goal is to have all three fields in the same record.

Thanks for your help!

Data type: Rephrase

  • Field: taskID
  • Field: Input
  • Field: Response

The API returns a “result” which is the “response” in the database, and the taskID.

Prior to the API response, there is a record in the database that includes the same taskID and the Input. I want to update the pre-existing record that has the matching taskID to fill in the Response data field returned from the API. The attached screenshot shows the preexisting record on the bottom and the result of creating a new record from the API response on the top. I want only one record.

Hi Ivan,

I assume the “Create a new Rephrase” is just there for you investigating the issue?

My main question at this stage would be why are you using taskID? You may have a really good reason for doing so, but it doesn’t make sense based on what you’ve shared so far.

It would be helpful to see some details of the workflow that’s calling this backend workflow - is it something you’re doing on a page, just after the task has been created?

In many scenarios, on the page you already know what Task you’re dealing with so you it’s better to pass the Task object (as opposed to the text taskID) as the parameter to the backend workflow.

But like I said, I might be missing something in what you’re doing to call this.

My gut feeling is that you are triggering your backend workflow before the task you want to update has been created - this can happen unintentionally, even though it seems odd and out of sequence.


Thanks again James,

Yes, the Create new Rephrase is just to investigate the issue.

The taskID is necessary for the API. The initial workflow is: User types in input–>POST request to API with input–>API immediately responds back with taskID–>Input and taskID stored in database–> API processes input (There is significant delay in processing the input, which is why I use a taskID through celery in my API)–> when API is finished processing, send POST request using backend workflow to bubble with the taskID and output.

There are scenarios where the app could be handling multiple tasks at once, so the taskID (I think) is necessary to keep the inputs and outputs in sync.

I would like to investigate further if I am triggering my backend workflow before the task, but I’m not sure that’s possible. To my knowledge, the backend workflow only triggers when the POST request comes in from my API. Given that there is a delay of at least a couple seconds that it takes my API to process, I don’t see how thats possible. The API doesn’t send the POST request until processing is finished. Also, when i troubleshoot using the Create a new thing, I can see the initial task get created, and then after a few seconds, the new thing appear in the database.

Thanks so much again for your help!

Okay, looks like you have set up a webhook or a public API and not just an API workflow that is invoked internally within Bubble application. (You’re sure it is needed to be done that way?)

One silly question, but since I have made such silly mistakes in past myself, just checking: When you did the testing, hope you did remove the object that got created because of your “create new thing…”? Otherwise it is possible that “search…” in update action is returning the object that you created in your previous test.

Hey Ivan,

Thanks for the detailed explanation. I’d assumed you were calling it from within Bubble, so your approach makes more sense now.

If the thing definitely does exist, perhaps it’s not being returned by your search. Which made me wonder…

Your receive-response API workflow is set to run without authentication, but isn’t set to ignore privacy rules. Are there any privacy rules set for your Rephrase data type? If not ‘everyone’ can see all Rephrases, those settings could explain why your workflow can’t search for and find the Rephrase it’s meant to update, but it can create a new one.

It’s a shot in the dark, but worth checking.


1 Like

That’s exactly what was wrong. The privacy rules were preventing the backend workflow from reading the taskID in the database. Checking the “Ignore privacy rules when running this workflow” worked. This is my first bubble app, so I’ll have to read up on the privacy rules to figure out the best way of implementing this.

Thanks again for your help!

1 Like

Great news and really glad I could help.

All the best with your project.