Execute with conditionals

Trying to figure out what is best practice in wappler.

I currently have 5 server side actions and each of these has a corresponding server connect.

  1. Pulls all open tickets.
  2. Pulls all overdue tickets.
  3. Pulls all tickets by user id.
  4. Pulls all closed tickets.
  5. Pulls all tickets by date opened.

Would it be better to move these server side API actions to the library, and create one api with conditionals that cause the correct library action to execute? 5 Server actions and 5 server connects is going to slow this app down quite a bit once load in all the production data.

consolidated my queries as much as I could.

Would be awesome if there was an isset() equivalent in wappler on server side and the ability to dynamically build a where statement by concatenating to it.

Hi.

You can just use the conditional conditions on your query builder to make it work in different ways.

So I’ve tried that with conditionals.

I had:
condition
then
query
else
query

It returned results for both queries, regardless how the condition was met. That seemed really odd so I changed it.

In past projects I usually build a dynamic where clause. So I can use the the same select and joins but change the results by adding to the where clause when a parameter is set. Typically I do this in a class and build the a $where variable if the parameters have values or a specific value. That seems very difficult, if not impossible, in wappler without writing custom code.

Not sure I get your point.
You are definitely doing something wrong.

The condition you are talking about is condition step. And there it no way it would run both then and else.

What I am suggesting is to is the question mark icon on conditions in query builder, which makes the contional run conditionally.

From my experience to make your life easier:

  1. Don’t use Library actions, they’re difficult to debug/preview (reason: pending feature request Preview Library actions)
  2. Use just one server action “get_tickets” instead of creating several with roughly the same intent
  3. Use Sid’s suggestion to dynamically build the “where concatenation” you’re looking for the Wappler way

I’ve used this project to learn wappler, coming from dev background… I’ve ignored that setting until now. I’ve learned something new about wappler! Thanks!

I’m having a hard time finding the “toggle condition” in the documentation, know which url might discuss it’s use?

@Romy can you help the user find the right documentation?

This isn’t docs but it might explain a little how to use this toggle condition in a query:

I am not completely sure what @stinknox is looking for. There is no specific tutorial for the “toggle condition”.

I will take a look at this while we build the new documentation! In the meantime, we apologize for the inconvenience.

The conditional expression that cause a condition to be added to a where clause.

Sorry can you please post a screenshot of the exact property you are referring to?

The question mark… i don’t see it referenced in the documentation. Does it affect the conditions above it or below it?

image

I think when you’ve added a couple of groups, it will become very evident which rules the conditions refer to. Eg:

image

Thanks!