How to organise a query to allow date range.

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
Rennur
Posts: 1191
Joined: Thu Mar 01, 2012 5:13 am
Location: Sydney, Australia

How to organise a query to allow date range.

Post by Rennur »

I'd like to have a form that a user can select a date range and then a query will display the records based on that range.
Issue is, I only have one field Transaction.Date and a query form only allows for that the user to enter that stored date, not a range.

This is probably a beginner question and if there is a simple procedure on how to achieve this please share.

Cheers
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Re: How to organise a query to allow date range.

Post by tford »

You can prompt the user for a FROM and TO date which you store in LoggedInRegularUser attributes. Then use those attributes in the query.
Tom - V8.8 build 3137 - MySql / PostGres
weblike
Posts: 1165
Joined: Sun Dec 02, 2012 12:00 pm
Location: Europe

Re: How to organise a query to allow date range.

Post by weblike »

Hi Rennur,
I'm using Tom's method for this kind of filtering.
Also Tom provided a quick tip about this here http://www.awareim.com/forum/viewtopic. ... ilter+demo

I never thanked Tom for this. Thank you Tom for this tip,I'm using it in every app I made.

Nice day all of you.
Thx,
George
________________________________
Developer Edition
AwareIM: v8.5, build 2824
OS: Windows Server 2012
DB: MySql 5.6.42
BenHayat
Posts: 2749
Joined: Thu Dec 23, 2010 5:48 am
Location: Fla, USA
Contact:

Re: How to organise a query to allow date range.

Post by BenHayat »

I found this in the manual. This is the way I've been doing it.
How to force users to enter parameters of the search
If you want a user to enter parameters of a search you need to specify a query that requires some of its parameters to be entered at run-time by the user (see the “Configuring Queries” section in the Aware IM User Guide). Sometimes you may want to force the user to enter a parameter. If she does not you do not want the query to run. The query parameters mechanism does not support mandatory parameters (if parameters are not entered the corresponding query condition is ignored). To force entering of query parameters you can define a temporary business object (with Persistence flag set to “Not persisted” – see the “Adding/Editing Business Objects” section in the Aware IM User Guide) with attributes that correspond to the parameters of the search. You can make some of the attributes mandatory by marking them as “value must be provided” – see the “Common Properties” section in the Aware IM User Guide). Then you need to define a process that will let the user enter the temporary object and then run a query. For example:
 
ENTER NEW QueryParametersObject
FIND Account WHERE Account.Status=QueryParametersObject.Status
Jhstephenson
Posts: 297
Joined: Wed Apr 22, 2015 11:44 pm

Re: How to organise a query to allow date range.

Post by Jhstephenson »

Ben,

I am just getting started with Aware so forgive me if this is a really newby question. I saw that paragraph in the user guide and thought it looked just like what I am trying to do. But, I am stuck somewhere.

How do you get the resulting query to display after creating the search criteria and running the FIND.

I have been playing with it and am pretty sure the FIND is working but then it immediately returns to the Search Criteria View instead of bringing up a list of the found records.

I am pretty sure I am just missing a small piece of the process somewhere.

Jim
BenHayat
Posts: 2749
Joined: Thu Dec 23, 2010 5:48 am
Location: Fla, USA
Contact:

Re: How to organise a query to allow date range.

Post by BenHayat »

Jhstephenson wrote:Ben,

I am just getting started with Aware so forgive me if this is a really newby question. I saw that paragraph in the user guide and thought it looked just like what I am trying to do. But, I am stuck somewhere.

How do you get the resulting query to display after creating the search criteria and running the FIND.

I have been playing with it and am pretty sure the FIND is working but then it immediately returns to the Search Criteria View instead of bringing up a list of the found records.

I am pretty sure I am just missing a small piece of the process somewhere.

Jim
Hi Jim;
Basically, a query is made up two parts. A query part using FIND action and also "Display Results". If you click on the Display Results button, it will show you a dialog box to select which attributes of object you want to see, but also, the width, height and other settings for the grid.
At this point you also introduce other actions to each row of the grid, i.e. Edit, VIEW or run a process an etc. To go further, you can even add Form menu and buttons. So the dialog box gives you lots of options.
Hope this helps.

Note: Be sure to watch the tutorials {many times} :D
BobK
Posts: 545
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: How to organise a query to allow date range.

Post by BobK »

Jim,

I assume you are running your FIND in a process. If so, change the FIND to DISPLAY.

If you want to control which attributes are displayed, do as Ben suggested and create a query and use DISPLAY with the query name.
Bob
Jhstephenson
Posts: 297
Joined: Wed Apr 22, 2015 11:44 pm

Re: How to organise a query to allow date range.

Post by Jhstephenson »

Thanks Bob, I have been trying to get DISPLAY to work with the following:

ENTER NEW QueryParts
DISPLAY ResultsOfQueryParts WHERE Parts.ClientInternalID=QueryParts.ClientInternalID

When I do that I get an error saying: rule " uses business object 'ResultsOfQueryParts' which has not been found

The ResultsOfQueryParts is there and when run by itself works just fine.

Someone suggested putting single quotes around the query name but that doesn't work either.

I am sure I am missing something really simple here, but can't seem to find it.
customaware
Posts: 2413
Joined: Mon Jul 02, 2012 12:24 am
Location: Ulaanbaatar, Mongolia

Re: How to organise a query to allow date range.

Post by customaware »

Hi Bob...

I suggested to Jim the same as you did regarding using DISPLAY QueryName but bumped into a brick wall.

So....imagine a non persisted BO MyParms with 2 Attributes MyParms.MaximumValue and MyParms.MinimumValue

I have a Part BO with 20,000 parts in it and an Attribute called Part.Value

I have a properly formatted Query called SearchResults to display my parts that has no WHERE stated in the QUERY.

Ok.... In a Process I can do this...


ENTER NEW MyParms
DISPLAY Part WHERE Part.Value>MyParms.MaximumValue AND Part.Value<MyParms.MinimumValue

Works perfectly and displays a non formatted table of all the Parts that satisfy the Query.

BUT..... and this is the same problem Jim is talking about and which I just naturally expected to work.....

ENTER NEW MyParms
DISPLAY SearchResults WHERE Part.Value>MyParms.MaximumValue AND Part.Value<MyParms.MinimumValue

Does not work.....
I was sure it is supposed to and I guess I am either using it incorrectly or it is not possible...

Any clues here as I feel like a bit of a dill.
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Image
BobK
Posts: 545
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: How to organise a query to allow date range.

Post by BobK »

Jim and Mark,

You can not have a WHERE clause when using DISPLAY with a query name.

I have not tested it, but I believe MyParms (Mark) and QueryParts (Jim) can be used in your respective queries. So, just remove the WHERE clause from your process and add them to your queries.
Bob
customaware
Posts: 2413
Joined: Mon Jul 02, 2012 12:24 am
Location: Ulaanbaatar, Mongolia

Re: How to organise a query to allow date range.

Post by customaware »

Yes... You are correct Bob.

The WHERE's need to be in the Query but can reference the attributes of the non persistent BO as it is in context when the DISPLAY is called.
I have tested this and it works.

I should have tested my previous response rather than making assumptions.

For what it is worth.... I have made the suggestion to Support that it would be nice (and I guess not to complicated) to add the feature to be able to incorporate the WHERE when using
DISPLAY as follows.....


DISPLAY MyBO WHERE MyBO.Atr1=.... AND MyBO.Atr2 etc USING MyQuery
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Image
Post Reply