Is it possible to pass a full JSON query (with data bindings within) from a server action form input to the Server Action for use in API Action call?

Hi all,

Working on our ElasticSearch query a little more this week. We’ve been playing with custom JS but it just feels like there should be a way to do this within Wappler UI.

Based on some advice in the forum, I’ve put all 29 input fields into a single form - that I could then trigger based on value changes.

The Server Action itself is an API Call that must be made with JSON.

So what I am attempting to do, is for each input it would have (this example for searching a job title):
{
“query”: {
“match_phrase”: {
“primary.job.title.name”: “Software Engineer”
}
}
}

The ‘Current Title’ input would pass this JSON and the “Software Engineer” is the data binding coming from the form input. We’d need to be able to add multiple, so “Software Engineer”, “Software Developer”, “Developer” etc.

In the Server Action side, I’d then think it might be possble to construct the full JSON call with a number of listed {{$_GET}} variables each tied to the form input.

So in theory, if the form input is empty, nothing gets constructed in the JSON before being sent to the API, but as that input has values - this then gets added to the full JSON query.

The big question is - is this even possible? Can I pass a JSON ‘section’ (probably wrong terminology) via a form input somehow to the Server Action to then be used in the API Call?

Alternatively, I could potentially construct each JSON section (aligned to each form input query) in the Query Parameters - and add the data binding in the value part there?

Ideally I don’t try this for days if it’s not possible within the existing Wappler UI?

Community Page
Last updated: