Do IF... Then, Case, Do While, Loop in Bubble workflow

Please tell me how to do some basic programming techniques below in Bubble workflows:

  1. IF…Then
  2. Case … End case
  3. Do While (loop) to do some things of scan record by record in a table in Bubble database.
  4. make query to do some action as query in SQL database:
    • Make the view to join some tables to view and report data
    • Add new, Insert, edit and delete records

Thanks!
Regards,
Long

1 Like
  1. Use “Only When”

image

  1. Just use multiple “only whens” to do the various tests. We don’t have this explicitly, but it is doable.

  2. This is “Schedule API Workflow” - so you run a “subroutine” on a list of records. Note that this is “a priori” in that you need to know the list of records in advance, you can’t (easily) do

“Joins” are implicit in the Bubble Database by the use of Custom Fields that link tables.

This is one-to-many join between Table A and Table B.

image

CRUD is via workflow actions…

image

2 Likes

Thanks MigelG!

It is very clear and helpfull with me, but how to do it In case primary key is two fields ?

Regards,
Long

In your search, test for the two fields existing.

Hi,

No, I mean the primary key is a pair (not individual one by one), please see example below

image

Primary key in Contract_Device table is Contract_Number + Device_Model then it is foreign key in Device_Assign table, please tell me how to:

  1. Manage the primary key in a pair in Contract_table (Contract_number + Device_Model) is not doublicate
  2. How to access Contract_Device table via foreign key from Device_Assign table, because I see in Define Primary Key option in Bubble setting do not allow us option primary key is a pair as picture below.

Thanks & Regards,
Long

  1. You manage it in “code” not in the database.

  1. That is somewhat confusing, it is NOT anything to do with Primary and Foreign Keys. It is just what field shows up when you link two tables.

In bubble, the way you link two tables is not via Keys. It is effectively via embedding the objects (things) in other objects (things). So sort of Object Relational. At least at the front end.

So… You have your Device Assign… in which you embed your parent. And remove the Foreign Keys…

image

And you embed a list of Device Assigns in Contract Device

image

That is the One-To-Many set up. The relations are set up by maintaining the list with add/remove. if you delete the child, it is removed from the parent list - So if you don’t want to do that … put the RI constraint in code.

You navigate the relation using “appostrophe languange”.

So you you have device assign thing, you can say …

image

Thanks NigelG! I have tried Loop with “Schedule API Workflow” to loop from 1 to N then call API Workflow, can you tell me how to loop to scan a table each record from the first record to last record?
Thanks and Regards,
Long

Yes, “Schedule API workflow on a List”. And make that list the entire table.

Can you send me a example in Bubble, it is easy to me to understand how it works.

Regards,
Long

Hi NigelG,
Can you send me a example, I need it for my app.

Thanks!
Long

HI Ihlong, I have the same problem that you explain. Do you have a solution how to solve this problem. Can you help-me please.
tks

1 Like