[Implemented build 3265] FR - separate the query UI from the search string

On this forum you can see a list of new features requested by users and you can also cast your own vote (you need to login to vote).
Post Reply
PointsWell
Posts: 1468
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

[Implemented build 3265] FR - separate the query UI from the search string

Post by PointsWell »

If you create a query it contains FIND ... WHERE and you can call that query anywhere you want using DISPLAY QueryName.

If however you have a complex query that you need to build on the fly there is no way to display this.

I have a query which usually has one criteria in it, but sometimes has two or more, e.g.

Code: Select all

FIND Job WHERE EXISTS JobMechanic WHERE (JobMechanic.obJob=Job AND JobMechanic.Name = 'Jacob'
Sometimes there are jobs that require two mechanics and the first query can't handle that, so it would need to be

Code: Select all

FIND Job WHERE EXISTS JobMechanic WHERE (JobMechanic.obJob=Job AND JobMechanic.Name = 'Jacob')
AND EXISTS JobMechanic WHERE (JobMechanic.obJob=Job AND JobMechanic.Name = 'Carl')
Mostly the query will be one mechanic, sometimes it may be two, in outlier cases it might be three.

I can't see a way to build that inside a query and you can't use EXEC_SCRIPT in a query formula to build the FIND statement outside the query place it into a non persisted BO and then EXEC_SCRIPT TempBO.QString.

You can use

Code: Select all

DISPLAY Job WHERE EXISTS JobMechanic WHERE (JobMechanic.obJob=Job AND JobMechanic.Name = 'Jacob')
AND EXISTS JobMechanic WHERE (JobMechanic.obJob=Job AND JobMechanic.Name = 'Carl')
But that results in a table of Job instances that is randomised and not meaningful and the operation on records is not controllable (and defaults to EDIT).

What would be useful is to be able to define the layout of a query and then be able to use

Code: Select all

DISPLAY Job WHERE EXISTS JobMechanic WHERE (JobMechanic.obJob=Job AND JobMechanic.Name = 'Jacob')
AND EXISTS JobMechanic WHERE (JobMechanic.obJob=Job AND JobMechanic.Name = 'Carl')
USING MyQuery

to override the query's FIND and insert the BOs that you've brought into context with the DISPLAY statement but laid out in the format of MyQuery.

Unless anyone else has encountered a way to make this happen another way.
Last edited by PointsWell on Wed Jul 03, 2024 11:52 am, edited 2 times in total.
customaware
Posts: 2418
Joined: Mon Jul 02, 2012 12:24 am
Location: Ulaanbaatar, Mongolia

Re: FR - Ability to show BO in context in a predefined Query's layout

Post by customaware »

Are you saying that ....

If I only have 1 Mechanic in Context, then I want this type of query
But
If I have 2 Mechanics in Context, then I want this other type of Query?

Will there be times you have n... Mechanics in Context?
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Image
PointsWell
Posts: 1468
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: FR - Ability to show BO in context in a predefined Query's layout

Post by PointsWell »

eagles9999 wrote: Fri Aug 18, 2023 6:52 am Are you saying that ....

If I only have 1 Mechanic in Context, then I want this type of query
But
If I have 2 Mechanics in Context, then I want this other type of Query?

Will there be times you have n... Mechanics in Context?
Answers in reverse order there may be n JobMechanics hence the bringing into context has to be dynamic and can't be placed into a query as a query is static

So when I said
I have a query which usually has one criteria in it, but sometimes has two or more
what I should have typed is I have a need for a query that is sometimes one criteria, sometimes two criteria, infrequently more.

The example above is very simplified the real query has multiple aspects but one part of it that can be one or more elements depending on other criteria.

Its 'easy' to get them into context, but its near impossible to get them into a grid to show in the UI.
customaware
Posts: 2418
Joined: Mon Jul 02, 2012 12:24 am
Location: Ulaanbaatar, Mongolia

Re: FR - Ability to show BO in context in a predefined Query's layout

Post by customaware »

Not totally sure if this will work Sean as I have not tested it.... but here is an approach that might work.

You want a dynamic number of Mechanics Names in the Query....

So, I would try and build a String .... say, SystemSettings.MechanicSearchString and assign the names you want....

ie. 'Jacob,Carl,Bob,Roger'

Then change this Query....
FIND Job WHERE EXISTS JobMechanic WHERE (JobMechanic.obJob=Job AND JobMechanic.Name = 'Jacob')
AND EXISTS JobMechanic WHERE (JobMechanic.obJob=Job AND JobMechanic.Name = 'Carl')

To This....

FIND Job WHERE EXISTS JobMechanic WHERE (JobMechanic.obJob=Job AND JobMechanic.Name IN SystemSettings.MechanicSearchString)

It might work.
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Image
hpl123
Posts: 2622
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Re: FR - Ability to show BO in context in a predefined Query's layout

Post by hpl123 »

Another solution is populating som temp parent BO with all you need and then run the query on that BO children. I do this here and there for complex scenarios or when Aware doesn't do what I want.
Henrik (V8 Developer Ed. - Windows)
PointsWell
Posts: 1468
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: FR - Ability to show BO in context in a predefined Query's layout

Post by PointsWell »

eagles9999 wrote: Fri Aug 18, 2023 10:13 am Not totally sure if this will work Sean as I have not tested it.... but here is an approach that might work.

You want a dynamic number of Mechanics Names in the Query....

So, I would try and build a String .... say, SystemSettings.MechanicSearchString and assign the names you want....

ie. 'Jacob,Carl,Bob,Roger'

Then change this Query....
FIND Job WHERE EXISTS JobMechanic WHERE (JobMechanic.obJob=Job AND JobMechanic.Name = 'Jacob')
AND EXISTS JobMechanic WHERE (JobMechanic.obJob=Job AND JobMechanic.Name = 'Carl')

To This....

FIND Job WHERE EXISTS JobMechanic WHERE (JobMechanic.obJob=Job AND JobMechanic.Name IN SystemSettings.MechanicSearchString)

It might work.
Unfortunately IN evaluates as an OR as in

Code: Select all

FIND Job WHERE EXISTS JobMechanic WHERE (JobMechanic.obJob=Job AND (
JobMechanic.Name = 'Jacob' OR 
JobMechanic.Name = 'Carl' OR 
JobMechanic.Name = 'Bob' OR 
JobMechanic.Name = 'Roger')
Which brings back all of the JobMechanic records and consequently all of the Jobs (if those were the only four mechanics)
customaware
Posts: 2418
Joined: Mon Jul 02, 2012 12:24 am
Location: Ulaanbaatar, Mongolia

Re: FR - Ability to show BO in context in a predefined Query's layout

Post by customaware »

I will try and knock up a demo over the weekend.
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Image
PointsWell
Posts: 1468
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: FR - Ability to show BO in context in a predefined Query's layout

Post by PointsWell »

This FR is more adequately described here
PointsWell
Posts: 1468
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: FR - separate the query UI from the search string

Post by PointsWell »

Implemented in build 3265
Post Reply