0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Query Builder】Filter : Preparing a lookup list by using a sub query

Last updated at Posted at 2024-09-24

Introduction

This time, I am writing about an extended setup for the query filter, using SunSystems as the product and selecting the Ledger Transactions table.

The three mandatory filters are automatically displayed as soon as the table is selected. I will use one of the filters, Account Code, to illustrate this post. While these filters are useful for narrowing down query results, there are additional filtering options available. For now, I will focus on just one of them: the Sub Query option.

Let's take a look.
image.png

Normal Use of the Filter

I use one of the filters, Account Code here.
image.png
Normally, I display a lookup list for the Account Code filter by clicking the lookup button or double-clicking in the filter fields, then selecting one or more account codes. This wouldn't be a problem if we didn’t have so many account codes; however, this product has a significant number of them.
Let’s explore how I can filter the account codes to reduce the number displayed in the lookup list.

The Use of Sub Query

Open the Filter Options dialog for the Account Code filter.
There is Filter based on Sub Query option on the dialog and it helps me to define a sub query to control the records to be shown in the lookup list.
image.png

Click Create Sub Query button to open Query Builder.
As you can see, the value for Business Unit filter is inherited from the parent query.
image.png
Choose Chart of Accounts table and 2 mandatory filters Account Type and Account Code are displayed.
We can manage the list of account codes with these.
image.png
If I leave those values as <ALL>, it behaves as the same as the normal use of the filter in the parent query.
I set D for Account Type this time so that the lookup list will show Debtor account codes only.
image.png

Set Account Code as the output item because this is for the lookup list for Account Code filter in the parent query.
Furthermore add Account Type and Description to help users understand the meaning of the account code.
image.png

Let's check what is displayed by clicking Preview button.
They will be displayed in the lookup list for the Account Code filter in the parent query.
image.png

Go back to query definition, and click OK to save the query.
Select Sub Query is used for Lookup value selection option.
image.png

Click OK to save the filter option dialog.
Now I am on the parent query.
Click Lookup button for the Account Code, it shows the same list as the one we saw in Preview of the sub query definition.
image.png
image.png

Conclusion

In this way, you can use subqueries to design lookup lists for filters.
I set a fixed value to the filter in the sub query. i.e. D for Account Type.
I think it works only a specific case, and we may need to use a dynamic value for the most of cases.
I will show you how I can do it with this post here.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?