Set input values based on API response on click: Do I have correct approach?

Hi all,

Just getting more and more understanding of this great platform.

Today I created a simple Dutch zipcode checker which automatically and directly fills street and city inputs based on the values zipcode and house number, using a free api set as type: Data. This was my end goal so that’s great.

I will share my implementation later in this post, and maybe I will try to make it a plug-in later.

Before managing this, I was first trying to trigger this api on button click by changing the API type to Action so that I could use it in the workflow as a Plug-in.

The API worked but from the workflow I didn’t get the response’s street and city values into the corresponding inputs.

So I just thought that I should have used custom states for this. A custom state for street and one for city. Using the workflow I than could have updated the custom states with the API response values and bind these states as values the desired input fields.

Then on change of either zipcode or housenumber I also would have cleared both custom states to clear the inputs for street and city.

Is this way if thought correct or is there another approach?

Custom states used that way will probably work.

A useful way to do this is to have a group, the data type set to the API return type, and inside the group, have inputs, their default content set to the group’s fields.

Then the workflow can clear the group, and set the group with a new or cached API response.

Cool. That’s just what I did in my end goal implementation now. The data source of the group is conditional and is set only when zipcode and housenumber are not empty. Otherwise it triggered the api without query parameters on page load. Returning to many results at once.

Questions:

  1. I want to call/trigger the api after button click in the worklflow, so therefore api type is set to action, but then I can’t set the data type of the group as the api response type, because then the api needs to be of type: data. Or do I miss something here.

  2. How can I clear the group and renew the data type’s data source from a workflow. I looked in the elements action section but there I didn’t find it. It mainly has actions to manage visibility. Or do I need to look better ;-).

Thanks!

The API connector should still setup a data structure you can use in the group.

Look again …
image