[Need Help] Conditional Update of "Thing" in my DB

Hello Awesome People!

I’m new to bubble and after long hours and two days of searching forums. I can’t find the answer to my problem.

I have two Data Types:

  1. Writer with the ff. fields
    Name - text (This field is a list: Disabled)

  2. Books with the ff. fields
    Title - text (This field is a list: Disabled)
    Author - Writer (This field is a list: Disabled)

I wanted to updated my DB with The Writer’s Name and Book’s Author so I have this in my Workflow.

When Button Save is clicked

Step 1: [Create a new thing]
Type: Writer
Field: Name = Input - Author’s value

Step 2: [Create a new thing]
Type: Books
Field: Author = Result of step 1 (Create a new Writer…)
Field: Title = Input - Book Title’s value

My Problem:
When the Writer and Book is new to my DB. I have no problem since it is all new entry. But I’m getting duplicate entries for the Writer if I add another book under his name.

So for example, my 1st entry is, Writer’s name is “JOEY” and Book Title is “Learning Bubble”, and my 2nd entry is, Writer’s name is “JOEY” (as he wrote a 2nd book) and Book Title as “Solving Bubble Problems”. Now, I will get duplicate “JOEY” entries since he was already added in the 1st entry.

What I’m expecting to happen is that:
If the writer name does not exist yet, then proceed to ADD the Writer’s name and the book title, but if the the writer’s name already exist, add only the name of the Book. (is this possible) ?

Thank you!
Denis

Hello
Depending on the style of your application, I suggest using backend workflows.
Likewise, you can distribute the book and author creation process in several custom workflows and then trigger them with a condition according to the situation.

1 Like

Just add a condition that checks if a Writer with that name already exists, and if not create one, and if so then make changes to it.

2 Likes

Hello Mahtab,

Appreciate your suggestion to separate the workflows and have a condition for each trigger.

Would it be possible for you to send some example here that I can test?

I added an event, When Button “Save” is clicked

Type: Writer
Name = Input - Author’s value
Only when: Search for Writer: count is 0 (Constraint is Name = Input - Author’s value.

So this works avoiding duplicate. Since when the Writer’s name already exist, it will not create an entry anymore. The problem is that my Step 2: will also not work since it is referring to the result of Step 1. If I try to edit the update of my “Author” then I’m getting this loop or error
image

(My exercise or test Application is Only Adding Books in the DB:)

Application:
image

Work Flow for the “Save” button
Step 1:

Step 2:

This is how my DB looks like:


Kindly help thank you!

Here’s how I would do it, using custom events and a search box instead of a regular input…

Add Book (bubbleapps.io)

2 Likes

Thankful @adamhholmes

You can use the same method.

The only thing that is not in this example is the solution for handling changes, which you can also model from these workflows and create a workflow in the backend for possible changes so that it is automatically triggered by changes in values.

Note that when creating the change database event, set the conditions so that it is triggered only in the specified state.

2 Likes

Thank you @adamhholmes !

This solution is really good and will fit to the App that I’m planning to do! Can you keep this app open so I can replicate this in my project please.

Thank you!

Also, Appreciate the help from @NoCodeDataArtisan !

You all are the best!

2 Likes

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