# Creating a data type with two lists, selecting one value based on corresponding value

**URL:** <https://forum.bubble.io/t/creating-a-data-type-with-two-lists-selecting-one-value-based-on-corresponding-value/307554>\
**Category:** Database\
**Created:** [February 14, 2024, 9:00pm UTC](https://forum.bubble.io/t/creating-a-data-type-with-two-lists-selecting-one-value-based-on-corresponding-value/307554 "2024-02-14T21:00:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![h.e.jacob](https://avatars.discourse-cdn.com/v4/letter/h/a9a28c/32.png) [@h.e.jacob](https://forum.bubble.io/u/h.e.jacob)\
**Post date:** [February 14, 2024, 9:00pm UTC](https://forum.bubble.io/t/creating-a-data-type-with-two-lists-selecting-one-value-based-on-corresponding-value/307554/1 "2024-02-14T21:00:53Z")

</div>

I have lists of text concerning files coming from an external API.

Each file has a file\_title and a file\_id. E.g. **File 1 = [“Title 1”, “ID 1”], File 2 = [“Title 2”, “ID 2”]**

I am trying to set it up so that users can select which file\_title they want on the front end and set up a dynamic workflow in the backend for file\_id.

E.g. if user selects “Title 2” in dropdown box then “ID 2” is dynamic value in workflow.

How am I able to do this?

I was unable to do it with custom states as there are two lists I want to save.

I tried creating a “file\_entry” data type with “file\_id” and “file\_title” fields. But when I “create a thing” from the external api it only saves Title 1 and ID 1. Which makes sense because we’re only creating “a” thing.

But if I set “file\_id” and “file\_titles” to lists, and set the lists on the api, then I get 1 “file\_entry” = [“file\_id” = (“id 1”, “id 2”) /// “file\_title” = (“Title 1”, “Title 2”)]

I hope that’s clear. Your input would be greatly appreciated 🙂

---

<div class="post-metadata">

**Author:** ![sondredoli](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/sondredoli/32/230381_2.png) [@sondredoli](https://forum.bubble.io/u/sondredoli)\
**Post date:** [February 14, 2024, 9:57pm UTC](https://forum.bubble.io/t/creating-a-data-type-with-two-lists-selecting-one-value-based-on-corresponding-value/307554/2 "2024-02-14T21:57:20Z")

</div>

Have you tried to create an API Workflow, and then “Schedule api workflow on a list” ?

Or you can use Bubble Data API bulk add.

Please share som screenshots an information regarding your API, so it would be easier to help you out here. 🙂

---

<div class="post-metadata">

**Author:** ![h.e.jacob](https://avatars.discourse-cdn.com/v4/letter/h/a9a28c/32.png) [@h.e.jacob](https://forum.bubble.io/u/h.e.jacob)\
**Post date:** [February 14, 2024, 10:31pm UTC](https://forum.bubble.io/t/creating-a-data-type-with-two-lists-selecting-one-value-based-on-corresponding-value/307554/3 "2024-02-14T22:31:51Z")

</div>

Thank you for your reply!

I’m not familiar with API workflow or Bubble Data API - I tried just now to experiment with it but it said I needed to upgrade my plan for Bubble Data API. Would you know of another solution?

Screenshot below of my external api data.

 ![Screenshot 2024-02-14 at 22.28.57](https://us1.discourse-cdn.com/bubble/original/3X/4/6/46aa5b2359f79e7499d119fe7ddde0f7d7a1c5d9.png)

---

<div class="post-metadata">

**Author:** ![ed19](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/ed19/32/193092_2.png) [@ed19](https://forum.bubble.io/u/ed19)\
**Post date:** [February 15, 2024, 12:39am UTC](https://forum.bubble.io/t/creating-a-data-type-with-two-lists-selecting-one-value-based-on-corresponding-value/307554/4 "2024-02-15T00:39:14Z")

</div>

I often end up doing weird bits of manipulation on multiple lists like this, as bubble makes it necessary far more often than it should be.

My suggestion would be to create a single list, and for each entry format it as:

File\_Title|File\_ID

When rendering for users on the front end, call the list, split each entry by | and show the first item. For workflows in the backend, you split by | and select the last item or item #2 (doesn’t have to be | necessarily, I just use it because it’s uncommon).

This way you won’t need to save anything to the db at all, and can keep your API call as a data action only.

---

<div class="post-metadata">

**Author:** ![h.e.jacob](https://avatars.discourse-cdn.com/v4/letter/h/a9a28c/32.png) [@h.e.jacob](https://forum.bubble.io/u/h.e.jacob)\
**Post date:** [February 15, 2024, 8:36am UTC](https://forum.bubble.io/t/creating-a-data-type-with-two-lists-selecting-one-value-based-on-corresponding-value/307554/5 "2024-02-15T08:36:23Z")

</div>

Hi Ed.

Thank you for your reply.

I tried creating something like that but I couldn’t manage to.

I was only able to creating a list of file ID and merge with a list of file Titles. Do you know how I would concentrate instead?

I apologise if this is very basic stuff - still have a lot to learn.

---

<div class="post-metadata">

**Author:** ![ed19](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/ed19/32/193092_2.png) [@ed19](https://forum.bubble.io/u/ed19)\
**Post date:** [February 15, 2024, 8:53am UTC](https://forum.bubble.io/t/creating-a-data-type-with-two-lists-selecting-one-value-based-on-corresponding-value/307554/6 "2024-02-15T08:53:58Z")

</div>

No problem at all!

If you don’t want to save the files to your database, you can call your API with a data action and structure the response as below:

Response’s files:format as text(this file’s title|this file’s id)

If you want to create a database entry for each file, just select “add list” to the list field on your datatype, then apply the same logic (format as text on the list of files)

---

<div class="post-metadata">

**Author:** ![h.e.jacob](https://avatars.discourse-cdn.com/v4/letter/h/a9a28c/32.png) [@h.e.jacob](https://forum.bubble.io/u/h.e.jacob)\
**Post date:** [February 15, 2024, 9:51am UTC](https://forum.bubble.io/t/creating-a-data-type-with-two-lists-selecting-one-value-based-on-corresponding-value/307554/7 "2024-02-15T09:51:55Z")

</div>

Thanks for the suggestion Ed.

The challenge I am finding with doing this is picking the corresponding ID in the backend.

So if Title1|ID1|Title2|ID2 is saved in a custom state, the user is then shown a split version of Title 1 / Title 2 on the front end. But how would I be able to translate their corresponding ID choice?

By merging the lists previously I was able to achieve a similar front end, but the obstacle is the backend ID.

---

<div class="post-metadata">

**Author:** ![ed19](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/ed19/32/193092_2.png) [@ed19](https://forum.bubble.io/u/ed19)\
**Post date:** [February 15, 2024, 10:43am UTC](https://forum.bubble.io/t/creating-a-data-type-with-two-lists-selecting-one-value-based-on-corresponding-value/307554/8 "2024-02-15T10:43:12Z")

</div>

Since you’re keeping the title and id joined in each entry, when you need to use it in the backend you would just split by | and get the last item instead.
