Set custom state object with text input on page


I have a custom state called operation-single. It is an “Operation” data type which has two text fields:


I want to add a list of Operations to another custom state called operation-multi which is a list of “Operations”.

Then when i am ready to save the data into the database i will write the multi operation unit into the database which is part of a Job data type. A Job data type has a list of Operations.

I cant see how i do this.

This is my design page - 2022-07-30_20-54-56.png

Then in the workflow i set the custom state to the data in the text boxes - 2022-07-30_20-55-13.png

The custom state is empty - 2022-07-30_20-58-38.png

Once i can get a list of these together it should then display in the RG.


Hey Ioan, welcome to Bubble!

It looks to me like the mistake here is your workflow step. In your workflow screenshot you’re making changes to the custom state operation-single. This custom state refers to one line of your Operations data table, meaning the Operation has to already exist before you can make changes to it.

The solution would be to do the workflow step ‘Create a thing’ and create the Operation with the name and owner, then set this to the custom state ‘single-operation’ if you still need to.

If I’ve understood you right, and you don’t want to create a line in the data table Operation straight away, then make two new custom states : OperationName (text) and OperationOwner (User), which you will be able to set from the two fields you show in your screenshot. Once you’re ready to create a line in the Operations table, take the data from the custom states OperationName and OperationOwner and use them in the ‘Create a thing’ workflow step.

I hope this helps, but it’s always easier if you explain in more detail the purpose of your app and why you’re creating these lists of Operations in custom states instead of writing them directly to the database.


Thanks for your response.

The reason i am trying to set the data into a custom state is because i need to gather the data of the larger Job before i send it to the database.

The Job data type has the following fields:

Job Name
List of Operations

On the New Job page i want to create a new Job record, but to be able to capture a list of operations at the time of creation.

As the Job record has not been created yet, i cant write the operations to the database.

So if i was able to store the operations in a custom state then when the user is ready to save the new job, then it can all be written into the database on the creation of the Job record.

Otherwise i would have to create the job, then edit the job. I want to do it in one action.

Here is a screen shot of the flow: 2022-07-30_21-36-34.png

  1. name the job
  2. add the job operations
  3. create the record:

Job Name
Operations (List)

Does that make sense?


Yep that makes much more sense now!

You’ve got two options:

  1. The seasoned developer option : create a table of ‘Job drafts’ which you create when the user opens this page. If they don’t click on ‘Add job’ it stays in their list of drafts and doesn’t get published to the real ‘Job’ data table. That would allow you to create each Operation when the user clicks ‘Add operation’ and add it to the ‘Job draft’ data. Once the user clicks ‘Add job’, you create a Job and for the field ‘Operations (List)’ you choose ‘set list’ and make it the list of the ‘Job draft’ list of operations. For database cleanliness, you could clear out every week the Job drafts that are more than 7 days old, for example, and even add a ‘Job’ field to the ‘Operation’ data table, so that if the ‘Job’ field of an Operation is empty and it’s more than 7 days old (in other words, it was made for a Job draft but never set to a real Job) then it can be deleted too.

  2. If you’re determined to make it work with custom states, you’re going to have a problem. You can’t use the custom state system to create data pairings (between OperationName and OperationOwner I mean). You’d have to create two custom states (list of texts) to store a list of OperationNames and a list of OperationOwners, then try to find some way to consolidate them when ‘Add job’ is clicked, such as by using a Backend Workflow on a list of things (send the list of OperationNames to the BackendWorkflow, plus the same item number of the list of OperationOwners). Otherwise, you could ‘Create an Operation’ every time the ‘Add operation’ button is clicked and use the workflow ‘Set state’ on the state ‘operation-multi’ in the following way : ‘Set state : index - operation-multi = index’s operation-multi :plus item Result of step X’s Operation’ - so the workflow sets the state as the existing state (list of Operations) plus the new Operation you just created. When the ‘Add job’ button is clicked, set the list of Operations in the Job as index’s operation-multi.

Hi Richard

Thanks for taking the time to answer my question.

So basically its not possible to have a variable that stores an object before you push the data to database.

Maybe i can create the job on the top part of the page, then hide / show the operations for that job. So its done in two steps and the job exists in the database.

How would i refer to the same job on the page?

So imagine a top part Job Name and a button Save Job, this is active in the first step. Once a job has been saved then that part is hidden and the operations section is made visible.

This is then the list of operations for the job we just created.

In other languages you can create an instance of an object and set the field parameters of those before doing any work on it (i thought that custom states would do that for me), i guess that is one of the limitations of bubble?

Thanks again