How to edit data fields based on conditions?

I have an API that returns some id’s (numbers ranging from 1-50) and have a separate git repo where they tell what each of these id’s represent (don’t know why they don’t have the names associated with id’s in the first place). So think of them as product categories say, id 1 refers to laptops, id 2 refers to mobiles etc. Now, I want to store the name of the product in my database based on the id that the API returns. Thought of solving this as a switch case statement but couldn’t find it in bubble. How to solve this?

Hi @anshjain232 welcome to the community!

Create an object (data type in bubblish) called category and give a text field called ID

Create the entries (50 could be inserted manually within the data editor)

Bubble will create meta-fields for each entry with one being a “unique id” to identify it in the system

So … essentially… each of your 50 categories will have their api-id and their bubble-unique-id. Add a title text field to display them in the UI (for “laptops”, “accessories”, etc etc)

This way you can recursively assign a bubble category to each entry of an array coming from api calls

Thanks, though it didn’t solve the problem. Please see if you can help further.

I have to add this category as a field in another data type. So, when I create the parent thing and edit it’s categoy field, I have to store a value in it according to the git repo as I told above. I want how to store the value of category field (conditionally, based on id returned by the API) while creating the parent thing, of this category field.

Hope this makes things clear. Any help is appreciated !

Object 1
Title (text)
Object 2 (object 2)

Use the action “make changes to a thing” and set object 2 (in the field object 2) to object 1

Actually, I know how to make changes to an object/thing. What I am asking is, how to make changes to a field of a data type conditionally? I know there is an “Only when” option but it becomes cumbersome when the number of conditions are close to 50 as in my case.

Correct me, if I was wrong in my interpretation!