Advanced conditional Server Connect actions

#1

Sometimes I have some pretty complicated server action files with a couple of nested levels to get to my result. Probably I’m not a good database designer or maybe I’m overcomplicating the structure, but I run into problems with app connect net being able to pick up the deeper nested actions. On Dreamweaver I thought it was my attempted single page apps with too complicated structure or limitations of Dreamweaver, but I’m splitting my pages and keeping everything quite simple, accept for the action files.

If this is limitation of the system/app, could I ask someone to maybe take time too draw up a diagram or table with details on how to manually type code to bind data. I’m getting it right with the hit and miss attempt but for instance this scenario I cannot get the binding right:

connection -> query -> repeat -> condition -> then -> query -> repeat -> 2 set values and 2 queries

Tried to make a paged query to limit result to 1 in the last query, but stuggle to bind to page then.

Wappler inteface gives me query and repeat - nothing more.

14

The bottom part after a connection and initial query looks like this:

Some guide till this works perfect would be great. I really do not mind hand coding and figure it out most of the time :slight_smile:

#2

Hi Marcel,

Good to see you are pushing the limits of Server Connect actions :slight_smile:

However your actions do seem way over complicated. Although possible you should try to keep them simple.
The major problem here I see is that you have a big condition that totally changes that output query.

The App Connect data picker on the front side - analyzes the server connect action and extracts metadata so you can pick from it. However if you have many conditional things that totally change the output data, it can not know what the eventual data will be, as your condition can change.

You can always enter the data expression by hand client side, but that is not really convenient.

Maybe you can explain your user case in detail, so I can advise you how to proceed in making more easier server connect actions with the same effect.

1 Like
#3

Thanks @George. Thought as much. And yes hand codig is not really convenient :slight_smile:

So this is what needs to happen on the bookings page for accommodation, similar to Airbnb:

The user searches for location from homepage. I’m using google places autocomplete and then saving the search info to db for site owner to see stats on searches. There I create var that I send with url param to results page. There are 2 types of searches - you can search to book or search to bid. That I also capture in db.

So the user hits the results page:

  1. URL param is used to recover saved record with his search details. That includes book or bid search type. this is from search table.
  2. I then repeat this query with results to be able to use output in condition -> Is this a bid or is it a book.
  3. If booking, Query db for all the places that are listed for bookings. This is from establishments table.
  4. Then I repeat this establihment query to use it’s id to filter rooms they listed since I need to display the From R 600 per person or per room price and I use set value on the rooms query to use minimum value for each, pp or per room.
  5. Lastly I do query on the images table to get the establishment’s main image. This one I only need to retreive 1 image, but because I struggle to get the binding path on a paged query, I used normal query.

Not sure if explanation is clear enough. Let me know if you need more details. Thanks

#4

So what is the problem of just having different server actions for the different results?
Why you need to make a conditional server action?

#5

I want to load bids when the first query returns bids and the selection and bookings if the user selected bookings, just did not want to return everything to front-end if not neccessary…

#6

One way to do this differently is to add the type as url param and the jump directly to condition without the 1st query and repeat…

#7

Well the way you usually do this is just have a conditional regions on the front-end that are enabled by the user choices. They contain their own data feeds (server connect actions returning the specific data) that are only executed if the conditional region is shown.

This way you achieve a good data balance and also isolation of the functionality. So it makes things much more easier to extend and maintain.

You really don’t have to stuck it all in a single over complicated server connect action as this will make your design way too complicated and it will be much more error sensitive if you don’t have your condition right or later on if you want to extend the condition.

So try to keep things as simple as possible - that is always the best way to go.

2 Likes
#8

Cool! I send more info through in the url param that makes it possible to remove the condition and a repeat!

Then on the page I have conditional regions that will only load the type based on url param.

Thanks for help @George and the challenge to not only use wappler better but applying better logic as a dev should.

You have no idea how I appreciate you guys at DMX Zone/Wappler!

47

1 Like