Constraint : Make Changes to a List of Things

Hi, basically i’ve successfully connected to the API for GPS system that tracks trucks. I’ve created a button, when clicked, it should pull the latest info for each truck into the database (Make changes to a list of things). Each truck has a unit_id that identifies the specific truck.

When I run the workflow, when clicking the button nothing happens. I know its something to do with the constraint. On the API side, only 1 location per truck (unit_id) is given at a time.

Thank You !!

FYI this is how the DB looks like, the “unit_ID” is a text on the DB and text as well on the API call type

Sorry I think I misread when writing my last reply. You’re trying to pull multiple items but your position_text is pulling the first items position_text. This may be the issue? It’s only pulling the first item?

also if you want multiple in a single data entry youll need to set the position_text to a list of texts.

Thank you for your response !!
I’m trying to pull “position_text” for each truck’s “unit_ID” into the database. However, nothing is pulling. If I take away the constraints, then everything is updated/pulled onto a single line, instead of the desired scenario where each “unit_ID” truck having its own “Position_text” updated. Position text is just a few words (i.e. 3km from the Canadian border)

What do you think ? Must be an issue with the constraint.

Would you be able to share a link to the editor and I could take a look and see what the api is doing?

Thank you so much for your response

The data looks like this

@allonp You are putting your constraint in the wrong place. You want to pull the entire list of GPS Tracking records. That’s the list you will be making a change to each item so you need all the records.

With the constraint you have, Bubble is looking for a GPS Tracking record with a unit_id that matches ALL of the unit_id’s you are bringing in from the API call. It is, of course, returning zero records with that constraint so that is why it appears as though nothing is happening.

Look at it this way, instead of filtering our database records by the API data, we need to filter the API data by our database records.

In the Make changes to a list of GPS Trackings, after your position_text = you will set your API call there as it is only where you have :first item’s position_text you want to change that to :filter:first item’s position_text.

Your filter constraint should be unit_id = This GPS Tracking’s unit_id.

Now, having said that, I would guess you could set up a GET call to the API that only brings in a single record. Then you would simply make that GET call and pass the unit_id to the API which says, just give me this record. That would be the simplest way to do this.

Interestingly enough, the modification date is updating but the “position text” isn’t yet feeding into the database

I checked with a “latitude” value and it’s the same problem.

Do you see any mistakes? Thank you so much!!

Remember, we are filtering the API data by our database record, not the other way around, so the 'unit_id = ’ in the constraint field is the unit_id of the records from our API call. Therefore it needs to be matched to the unit_id of our database record.

Your filter constraint needs to be unit_id=This GPS Tracking’s unit_id not ‘This GPS GET root row’s unit_id’.

The reason this works is that making changes to a list of things is not a single operation. It will run a separate operation on each item in your list and ‘This’ refers to the current record being modified.

So imagine all your database records laid out in a list and we are saying, "ok, Bubble, go get all of the current GPS positions and for EACH RECORD in this list filter the list of GPS Positions to match that specific record.

I don’t see THIS GPS tracking unit under the filter. What do you think?

I tried “do a search for”… But didn’t have any luck

Thank u!!

Hmmm, I just checked the process in a test app and, you’re right, it isn’t available in the filter constraints. Have you looked into creating a GET call that pulls in a single record from the API? I know you can pass This record information through an API call parameter.

1 Like

I’m going to try this
Thank you so much for all your input, reality appreciate your time

1 Like

I figured it out without using a GET CALL single record.
All I needed was a second filter !! A filter inside the first filter. This allowed me to