"Search for" inside "Make changes to thing" giving weird results

Hi Bubblers,
I am seeing some strange behaviour when “Making Changes to a Thing” combined with a “search for” function.
Am I using the search for function incorrectly?

I’ve added an example App to the forum_app2: make_changes_to_thing

Here is my problem:

  1. I have three* text fields with the following entries:
  • text 1= Bubble
  • text 2 = BUbble
  • text 3 = bubble
  1. I then add them to an empty Keywords table by using the make changes to thing event:
    2.1. Search for “Keywords” (table)
    2.2. Where Keywords (field) = text1 lowercase
    2.3 Create thing if it doesn’t exist
    2.4 add Keywords = text1 lowercase

  2. I repeat Step 2 for each text field

If I do this on a Keywords Table that already has at least ONE “bubble” Keyword in it, then the app doesn’t add any new Keywords. - This is good, and what I would expect!

HOWEVER, if I do this on an EMPTY Keywords Table, then the keywords from the text fields are added THREE times.
It is like it is not finding the first entry (created for text 1) while it is running the workflow and then just keeps adding the keywords until it has finished the workflow.

Does anyone have any ideas how I can prevent this from happening?

Thank you,
Toby

I’m pretty sure this is a bug.

I’ve had an extensive look at this - you can see what I’ve done on your page. I’m pretty sure this is a bug, relating to how quickly the result is stored in the database. I think the second and third read checks are being done on the database before the write check is complete.

I have got it working by scheduling 2x workflows 1 and 3 seconds in the future and it works OK (though you have to manually refresh the page to see all the data updates). If I schedule the workflow -1 and 1 seconds in the future, it creates two entries, i.e. the first check is happening too early.

Thank you very much @mmcconna Moray for taking the time to look at this. I am glad I am not going completely insane as I’ve been scratching my head on this for a few days now.
And yes, I think you showed nicely why this is happening. I did the same test with the delayed call and got the same results. Now I also know how to call things delayed by a few seconds :slight_smile:

Hi @Bubble team - have you guys seen this before and if not, do you think this can be fixed?
I am looking at an alternative method (storing data as invisible Repeating Group, selecting unique items and then storing it again in another table that I then show as a new repeating group) but my workflow is starting to get pretty complex for such a simple task and I need to do this for each Keyword I pulling back from an API (~15 keywords).

Thank you for your help!

That’s quite odd.

A simpler way of doing it (rather than delayed actions) is to have three events trigger from the same button press.

What is also interesting is that the backend seems to do the create (and deletes) before the workflow has actually run. So it doesn’t wait for the debugger.

1 Like

Please file a bug report and we’ll take it from there.

Looking at it more, I think it’s because we evaluate actions parameters at the beginning of the workflow and use this when running the actions. We do this to prevent unpredictable results. It’s more of a design choice than a bug. Can you find a workaround?

1 Like

This does mean it is very hard to debug things, as you seem to do all the “database” actions up front ?

The workaround I came up with us to schedule workflows ahead but I think this is non-ideal.

Do scheduled workflows do their data operations independently? In one of my examples, future-scheduled workflows seemed to be independent, but past-scheduled workflows seemed to be non-independent.

What are the unexpected outcomes you are trying to avoid? Without knowing that the design choice seems a bit odd to me. I suppose it is a bit like a “transaction” in SQL - except even there constituent parts of a transaction can see their own results, it’s just things outside the transaction which see the transaction as atomic.

Could you maybe change things so that each workflow does its data operations independently? That way “normal” workflows behave as you want, but if you need to rerun data queries in a workflow expecting to see changes you made, you can trigger custom events to do that. Actually that sounds quite hard.

Second the comment about debugging being difficult in this scenario.

Not sure why you wouldn’t have three events. It seems to work and is simple.

Hi Emmanuel,
I’m not sure I know how I could trigger these database actions differently other than by:

  1. scheduling the workflows to run at a later point the way that Moray did - then the user has to wait 1-2 seconds for each entry to be made. I return 15 Keywords so that would be 30 secs for each round and I call that twice.
  2. having the user manually kick off the process for each keyword with an action button. That would be 30 clicks.

If you look at the workflow for the “Store as TEXT is clicked” it seems that bubble is not seeing the database entries that are being created by the previous workstep if it relates to a database action. All other actions it recognizes.

My only other alternative is to:

  1. store all database entries as duplicated in a separate temp table
  2. convert the rows to text list
  3. run a “search for unique” action against the text list
  4. store each entry from the text list in a different table.

– it works but it is starting to become a massive workflow with 4 events that I loop through 30 times…

I’m glad I found this thread- I’m also having issues running concurrent ‘Make changes to’ and creating new rows by utilizing ‘Create if thing doesn’t exist’.

My issue is that the values in the first row created are always added to the second new row created.

Here is the table with the two newly created rows.

Here is the workflow:

I’m also going to try separating these ‘Make changes to’ actions somehow to see if that does the trick.

Otherwise any input on this would be great.

Look at the debugger (mode STEP BY STEP). You probably find the answer.

Unable to use the debugger for this- it skips over all of the ‘Make changes to’ actions. I actually wrote a post about that, too (which links to this post, lol).