How to Edit & Save data returned from API

The screenshot below shows the return data of a Zip Code radius call.

This radius call is a step in creating a New Staff profile that includes creating a Service Area.

If some of the zip codes returned is outside of the staff’s service area & needs to be deleted, what’s the best process to do this? (i.e Clermont Co is outside of the staff’s Service Area and should not be saved as part of this staff’s Service Area)

Screen Shot 2017-06-26 at 1.13.11 PM

Thanks for any suggestions

Screen Shot 2017-06-26 at 1.13.11 PM

I’m not the biggest expert here, but have a list of served counties in the DB and only show counties that match any entry in the query?

Hi @pier2design,

Thank you for your suggestion. I’m actually trying to save the whole line of data to display at a later time.

Any other ideas?

@fayewatson

Can you make any sense out of this post? I’m still struggling to edit & save data from an api call.

Appreciate your time.

To do this you can Schedule an API workflow on a list (the list being the repeating group you have now), in order to save each line as its own Thing in the database. :slight_smile: Here is a great example by Nigel:

https://buildingonbubble.com/block/save-an-apis-results-1472017471956x981892223072469000

Once that’s saved, then you can allow the User to edit and remove certain entries from their service area.

1 Like

@fayewatson

Thank you for this suggestion. I tried to implement this and found out I needed a paid plan for the API schedule to work. I have since done so but trying to create a API schedule is looking pretty foreign to me. (non-tech, new to Bubble Dreamer)

Can you help?

Definitely! In your app’s Settings tab, you’ll first want to go to API, and check:

Once you do this, you can click in the Page/Resuable Elements Panel, and the API Workflows option will appear beneath your reusable elements here:

Then, within your API workflows you’ll create a new endpoint. It depends on your app’s data structure, but in Nigel’s example the endpoint has these settings/keys:

Here, the keys can be any word(s) you prefer (sort of like a label). It depends on your data structure which stores the Service Areas for each User, but you could have a custom data type such as ‘Service Area’ with an address field. This way, you could have a key such as ‘address’ type: address. Then add any other keys needed for other fields within each new ‘Service Area’ that will be created.

In Nigel’s example he has a custom data type called Place with two fields: Name and Address. In the API endoint, he has a Create a New Place action which uses the keys as the values for each corresponding field:

Then back on the page, he has an input, a save button and list of results in an rg:

The workflow for the Save Places schedules the API workflow on a List of Things (the list of things being the repeating group):

Here the ‘keys’ name and address appear again, and he defines the values for those keys setup in the endpoints. So, this was confusing to me for a while (and there are probably clearer ways to explain it than I can!), but the API endpoint Create a New Thing fields’ values are keys. And keys’ values are different data sources defined in Schedule An API Workflow On A List action, defined on the page(s) where you need this workflow to run. Here it’s:

Once the key values are set up, and the action is run in preview mode, this workflow will run on all items in the list you define (Bubble will go one by one down the repeating group until a new Thing has been created for each row).

If you run into any trouble, feel free to let me know and I can definitely assist in setting this up! (Can PM me a link if you prefer). But this should save the addresses correctly. :slight_smile:

2 Likes

Yay! I got it to work with the help of your exceptional instructions.:slightly_smiling_face:

Now, I need to figure out how to display ONLY the service areas that were JUST saved to the database in order to delete the ones not needed. Currently the way I have it set it pulls ALL the saved areas from previous saves into the repeating group.

Suggestions?

1 Like

Awesome! :blush: Do Service Areas belong to a User? If so, you can filter the repeating group of Service Areas created in the API workflow using “Created By = Current User” as long as the User was logged in when clicking the button which Scheduled the API workflow.

You could also add a constraint to the Created By field and show Service Areas that were created by the User in the last hour? Or, add a second action in the API endpoint which adds that Service Area to a Current User’s List of Service Areas, then display that list in a repeating group?

1 Like

How do I set up - “You could also add a constraint to the Created By field and show Service Areas that were created by the User in the last hour?”

If I could I would like to narrow it down to the last 3 mins.

In the repeating group which displays the results of the API workflow, you could add two search constraints:

Alternatively you could place a list of ServiceAreas on the User, and then add a second action to the API workflow which adds each newly created ServiceArea to the Current User’s ListOfService Areas field (type: Service Area, list: yes)

Then the repeating group data source would instead just be:

1 Like

That worked, we’re almost there! How do I clear out the repeating group of Service Areas if I want to allow the user to do a do-over? Right now it adds to the list & I can only delete the “first item” or “last item” from the repeating group.

You can use ‘Delete List of Things’ to remove the all of the recently created Service Areas by that User:

(With the list for “Delete a List of Things” being the “Repeating group of Service Areas List of Service Areas”). Then navigate the User back to the first step of saving a list of Service Areas to do the do-over.

1 Like

Again, works like a charm! Thank you :grinning:

Do you have any suggestions on what to show as the Service Areas from the API workflow are being entered in the repeating group -one by one. (To indicate “processing” and/or “finished”)?

1 Like

My pleasure! :grinning:

You can do this by creating a conditional statement on a loading icon or text, such as:
“When [The List of Google Places that the API is scheduled to run on]:count is not [Repeating Group of Newly Created Service Areas]:count” --> this element is visible. *With the text or image set to not be visible on page load.

This way, it will become hidden again when the Service Areas have all been created/stored in the database.

1 Like

I sent you a link. Could you set this up for me?

BTW I only have 50 Calls daily, so if you need to test you may want to keep it within 1 mile.

1 Like