How to ensure Database Query does not return all records if condition is not met?

I was hoping the Conditions tab’s condition field would ensure nothing is returned if the condition evaluated false. Unfortunately, it’s returning all records when the condition evaluates false.

Is my only option to add a condition step before the database query step to keep the query from being run?
image

Keith you have the same exactly condition in the 2 cases?
The only difference in your queries is that in the first example you have set a toggle condition?

I mean:
the first case

and the second case (inside the If)

On the first case you run the query anyway but if the toggle condition is true THEN the condition is applied and the query gets filtered (false = all the records)
On the other case, you just DON’T run the query at all if the condition is false (false = 0 records)

Thanks @famousmag. I understand the logic. I was just hoping the Condition would keep the query from running at all.

image

That’s not the case, so it looks like my only option is to add Condition steps before the database query.
image.

That means I end up with a more difficult to read flow.

1 Like

Yeah… They are completely different things… (false toggle = no condition)

1 Like

I think you can do a trick…
Let me see for a minute

I’m not able to understand your logic there (its late for me, my brain is out of order…) but I think I have done something similar to filter an order list that i needed…

I used an extra “switch” (setValue) before the query that I used inside my query condition.

Is there any way to do:
setValue usrSwitch = UserRoleCheck.PermissinNames.contains(‘user_list’)?-1:999999999999

Then

This switch and the condition is used in order to eliminate the chance of a match in your query.

I assume that the user.Account returns always a value >=0…
If the contains is true then you have usrSwitch=-1 and then the user.Account will not much the condition
You can adjust the switch (numeric, string etc) and the condition (greater / less) to your needs

Just an idea… Maybe you can adjust it to your needs

Thanks @famousmag! I think I’ll stay with the condition step for now and not run the database action at all if the condition step is not met.

1 Like

If I understand you correctly:

You need to know if a query has items and then running a query, but you are using this:
image
So it will return all?

Why don’t you try this:


If this returns values:


Then you run this:
image

You can make a condition and use a Server Array List and then bind the items on the App Connect

Apologies if I missunderstood it, bad english around here :slight_smile:

Hi @franse, I was attempting to use the Condition’s condition to keep a user from being able to perform the database query.

For example, if a User does not have the user_read permission, then do not allow them to run the database query operation. Unfortunately, the condition field on the Condition’s tab does not work like that. It only keeps the condition (AccountUser.Account == UserRoleCheck[0].Account) from being used. The database action will still run just without the condition, so in a database query step it means that all records will be returned.

Well the condition in the filters tab is only user to apply the filter or not.
If you want to conditionally run a database query use the condition step in server connect.

Thanks @Teodor. That was the conclusion I came to as well.