Is it possible to use a form for not adding data to a table, but just to gather data and send it to a REST service?
Let’s imagine an experiment: There is a trivial service like this to add numbers, https://api.val.town/v1/run/ralfw.Add?args=[41,1]. In a Glide app I want to give the user the option to add numbers A and B - and call this service behind the scenes. The UI could look like this:
How do I manage to do that? It seems, a form always needs to be attached to a table. That’s not, what’s needed here, but ok if inevitable.
It also seems, I need fields for the data to enter in this table, eg fields for A and B in this example. Well, that’s ok, too, if inevitable.
But what’s not working for me is, that a new row is always created when I press the submit button of a form.
I cannot hide the button, I cannot replace its action.
Or am I missing something?
How can I replace (!) the default action? (Or at least not add a new record to the table, but change the current record, eg the current user.)
Also, of course, how to display the result of a REST call? The form always closes when hitting submit, it seems. Or can I keep it open to display a result?
Why does it have to be a form? Couldn’t you use a detail screen or edit screen ?
I’m open to everything But a detail/edit screen is attached to a table to and eager to add/store field content. Ok, an edit screen would just store it; that would be a step forward.
But how to get into edit mode right away from the menu or a tab icon?
How to get rid of the default buttons? (Just hide them? )
I guess I’d add a custom button to trigger the REST call. Right?
Just use a single row helper table, with User Specific Columns for your inputs. This will allow multiple users to use it at the same time, all writing their own values to the same columns in the same row.
Then call the API using the Fetch JSON column.
I now was able to get rid of the add:
- Create a REST call table with columns for the params, eg A and B.
- Create a screen for that table.
- Delete the collection on the screen!!! // Very important step. That way only the first record gets shown/edited.
- Place entry fields for A and B on the screen.
- Add a JSON fetch column to the table and parameterize its URL with A and B.
- Show fetch column value on screen.
Whenever I change the values A or B the call is made and the updated result is shown.
No record gets added. All happens on the user specific fields of the first and only record in the table.
For now, yes. Or use Webhook + Make.
But… there is a new feature on the way that will allow you to make POST requests. Even authenticated ones, and do it securely. I don’t know exactly when it will land, but I believe it’s quite close.
A REST request action would be great!
In the meantime I used a JS column:
The REST call is triggered whenever A or B changes. That’s not, what I want - but ok for now.
I guess I could decouple data entry from REST call with a button and a “set value” action. The action could copy the value from A and B to “parameter columns” pA and pB which then are used by the JS column.
Let me try…
Exactly - that would have been my next suggestion
oh, btw… I just noticed the
And it works very nicely The button just has to trigger “set values”. No custom action necessary.
What to do with errors during the JS function execution? (console.log does not work.) I guess I just would need to add an interpretation of the field value with an if-then column. Eg. if the col contains “error”, well, an error occurred, otherwise its a valid result. But that’s a detail.
One more question: How can I display an hourglass or the like while (!) the REST call is running?
“Show notification” just pops up and disappears
Please use the new
Call API column/action for this. You can enable it in Previews.
Turns out it was very close
You should make claims like that more often so that we get more new features.
A great feature - but as it turns out not worth upgrading from the free plan I’m still using. Sorry.
My use case is not suffering from CORS issues, hence I’m happy with a client side JS fetch().
For now at least.
See my view on the free plan here.