1 answer
- 10-1
The button should make a call to Joget server then, from the Joget server, it will make the actual call to the actual external rest api. You can write some javascript to make POST call to point to a UI menu such as form that use JSON Load Binder to make the call.
- Nik
"The button should make a call to Joget server then, from the Joget server, it will make the actual call to the actual external rest api."
How can this be done? The only way I know to make rest call from the backend (joget server) is with JSON API. But this can be used only under certain circumstances. After form submitting and in Process Tool. In my case there is a button that doesn't have to do with form submitting. So there is only the second option. The only way I can thing of to use it is to make a process with JSON API Tool. But processes have a disadvantage. They use joget UI (they show a result page). And the only visual function we need is to place the result of the rest api to a field of the form. All the others must be done in the background silently. Throughout this action, the form page should remain as it is and there should be no distraction to another page as would happen with the process.
"You can write some javascript to make POST call to point to a UI menu such as form that use JSON Load Binder to make the call."
This is a solution only if we had to fill the field from a rest api call when the form is loaded. But here this is not the case. I need to fill the field asynchronous. After the form load and when the user clicks the custom button (not the save button).
On second thought... unless you mean hijacking. That is, creating a fake form just to call the JSON API. It seems like a very rough solution to me. How will I manage the API return to place it in the first regular form while it has been called from the fake form.
This all seems a bit unnecessarily elaborate to me.
It seems inconceivable to me that you can't make a simple http call to an external api from a button without messing everything up and after a while not being able to maintain it.
Add your comment...
I have a form. I need a button next to or below a field that calls an external rest api (http request in practice). The api returns a value that should be filled in the field. Also because there will be API key in the rest api and to avoid CORS error the call must be done from backend and not from frontend (like an ajax or fetch call).